diff --git a/.gitignore b/.gitignore index 8d321f7..3b3f041 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,32 @@ +# Dependencies node_modules +.pnp +.pnp.js + +# Testing +coverage + +# Turbo +.turbo + +# Build outputs build +dist +out + +# Misc +.DS_Store +*.pem stats.html + +# Debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Local env files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local diff --git a/.npmignore b/.npmignore index c1aea8a..3262ec1 100644 --- a/.npmignore +++ b/.npmignore @@ -1,12 +1,15 @@ -example +demo-app node_modules src +configs .prettierrc .eslintrc .editorconfig +.turbo dev-server.mjs esbuild.config.cjs tsconfig.json meta.txt meta.json eslint.config.mjs +esbuild.config.js diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..c129521 --- /dev/null +++ b/.npmrc @@ -0,0 +1,3 @@ +engine-strict=true +resolution-mode=highest +save-exact=true diff --git a/LICENSE b/LICENSE index 873032b..ceeffa1 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 Julian Ćwirko +Copyright (c) 2024 Julian Ćwirko Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index ddf4bf3..dff9f19 100644 --- a/README.md +++ b/README.md @@ -1,167 +1,3 @@ -## ElvenJS +## Elven monorepo -### One static file to rule it all on the MultiversX blockchain! - -## Docs -- [www.elvenjs.com](https://www.elvenjs.com) - -## Videos -- [JavaScript browser SDK for MultiversX Blockchain](https://youtu.be/tcTukpkjcQw) - -## Demos -- [elvenjs.netlify.app](https://elvenjs.netlify.app/) - EGLD, ESDT transactions, smart contract queries and transactions -- [elrond-donate-widget-demo.netlify.app](https://multiversx-donate-widget-demo.netlify.app/) - donation-like widget demo -- [StackBlitz vanilla html demo](https://stackblitz.com/edit/web-platform-d4rx5v?file=index.html) -- [StackBlitz Solid.js demo](https://stackblitz.com/edit/vitejs-vite-rbo6du?file=src/App.tsx) -- [StackBlitz React demo](https://stackblitz.com/edit/vitejs-vite-qr2u7l?file=src/App.tsx) -- [StackBlitz Vue demo](https://stackblitz.com/edit/vue-zrb8y5?file=src/App.vue) - -Authenticate, sign and send transactions on the MultiversX blockchain in the browser. No need for bundlers, frameworks, etc. Just attach the script source, and you are ready to go. You can incorporate it into your preferred CMS framework like WordPress or an e-commerce system. Plus, it will also work on a standard static HTML website. - -The primary purpose of this tool is to have a lite script for browser usage where you can authenticate and sign/send transactions on the MultiversX blockchain and do this without any additional build steps. - -The purpose is to simplify the usage for primary use cases and open the doors for many frontend tools and approaches. - -It is a script for browsers incorporates ES6 modules. If you need fully functional JavaScript/Typescript SDK (also in Nodejs), please use [sdk-js](https://docs.multiversx.com/sdk-and-tools/sdk-js/), an official Typescript MultiversX SDK. And if you are React developer, please check the [Nextjs dapp](https://github.com/xdevguild/nextjs-dapp-template). - -**You can use it already, but it is under active development, and the API might change, there could be breaking changes without changing major versions.** - -### How to use it - -Copy and include the `elven.js` script from the `build` directory or the best would be to use CDN (https://unpkg.com/elven.js/build/elven.js). Please don't link the script using the [demo](https://elvenjs.netlify.app/) domain. - -Use module type, like: - -```html - -``` -or from CDN: - -```html - -``` - -### SDK reference - -Please check the docs here: [www.elvenjs.com/docs/sdk-reference.html](https://www.elvenjs.com/docs/sdk-reference.html) - -### Recipes - -Please check how to use it with a couple of recipes here: [www.elvenjs.com/docs/recipes.html](https://www.elvenjs.com/docs/recipes.html) - -Check for more complete examples in the [example/index.html](/example/index.html) - -### Usage example with static website (base demo): - -Check out the example file: [example/index.html](/example/index.html) - -You will find the whole demo there. The same is deployed here: [elvenjs.netlify.app](https://elvenjs.netlify.app) - -### Usage in frontend frameworks - -Elven.js can also be used in many different frameworks by importing it from node_modules (of course, it is a client-side library). When it comes to React/Nextjs, it is advised to use one of the ready templates, for example, the one mentioned above. But Elven.js can be helpful in other frameworks where there are no templates yet. Example: - -```bash -npm install elven.js -``` -and then in your client side framework: -```typescript -import { ElvenJS } from 'elven.js'; -``` - -The types should also be exported. - -### What can it do? - -The API is limited for now, this will change, but even now, it can do most of the core operations: - -- authenticate using the xPortal mobile, MultiversX browser extension, MultiversX Web Wallet and xAlias -- integrate with xPortal Hub -- handle expiration of the auth state -- handle login with tokens to be able to get the signature -- sign transactions -- send transactions (also custom smart contracts) -- sign custom messages -- basic global states handling (local storage) -- basic structures for transaction payload -- sync the network on page load -- querying the smart contracts (without tools for result parsing yet) -- support for guarded transactions using MultiversX 2FA solutions - -### What will it do soon? (TODO): - -- authenticate with Ledger Nano -- result parsing (separate library) -- more advanced global state handling and (real-time updates (if needed)?) -- more structures and simplification for payload builders -- split it into more files/libraries -- make it as small as possible - -### What it won't probably do: - -- crypto tasks -- results parsing (but it will land in a separate package) - -Why? Because it is supposed to be a browser script, it should be as small as possible. All that functionality can be replaced if needed by a custom implementation or other libraries. There will be docs with examples for that. And in the future, there may be more similar libraries, but optional and separated. - -### Development - -1. clone the repo -2. `npm install` dependencies -3. `npm run build` -4. test on example -> `npm run dev:server` -5. rebuild with every change in the script - -To test the MultiversX browser extension you would need to run localhost with SSL. -For quick dev testing tools like [localhost.run](https://localhost.run/) should be enough. -After you run `npm run dev:server`, in separate teriminal window run `ssh -R 80:localhost:3000 localhost.run`. You can also relay on your own SSL setup. - -### Articles - -- [How to Interact With the MultiversX Blockchain in a Simple Static Website](https://hackernoon.com/how-to-interact-with-the-elrond-blockchain-in-a-simple-static-website) -- [How to enable donations on any website using the MultiversX blockchain and EGLD tokens](https://dev.to/juliancwirko/how-to-enable-donations-on-any-website-using-the-elrond-blockchain-and-egld-tokens-3fkf) - -### TODO -- [Kanban board](https://github.com/elven-js/projects/1) - -### Other tools - -If you need to use MultiversX SDK with React-based projects, you can try these tools: - -- [sdk-dapp](https://github.com/multiversx/mx-sdk-dapp) - for standard React-based SPA -- [nextjs-dapp-template](https://github.com/xdevguild/nextjs-dapp-template) - or Nextjs apps -- [useElven](https://www.useelven.com) - React Hooks for interacting with MultiversX blockchain - -If you are interested in creating and managing your own PFP NFT collection, you might be interested in: - -- [Elven Tools](https://www.elven.tools) - What is included: NFT minter smart contract (decentralized way of minting), minter Nextjs dapp (interaction on the frontend side), CLI tool (deploy, configuration, interaction) -- [nft-art-maker](https://github.com/juliancwirko/nft-art-maker) - tool for creating png assets from provided layers. It can also pack files and upload them to IPFS using nft.storage. All CIDs will be auto-updated - -Other tools: - -- [Buildo Begins](https://github.com/xdevguild/buildo-begins) - all MultiversX blockchain CLI interactions with sdk-js, still in progress, but usable -- [Buildo.dev](https://www.buildo.dev) - Buildo.dev is a MultiversX app that helps with blockchain interactions, like issuing tokens and querying smart contracts. +TODO link other readmes diff --git a/TODO.md b/TODO.md index cd460ea..6f8a2d7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,14 +1,15 @@ -- move all previous signing providers (wallet connect is left) - - check what can be done with wallet connect to make it as small as possible -- think about moving xPortal and webview integrations to separate files ???? +- remove callbacks from the API - base everything on promises +- prepare a new API for token operations +- prepare a new API for smart contracts interactions - the the best would be to pass the arguments as is (always requiring ABI without typed helpers ???) + - pass ABI as link to a file or as content or both? +- check and handle all the errors for the mobile provider when the provider is not initialized etc. - add tests for at least most used utilities, maybe some core tools, check tests in MVX SDKs (more tests can be added later) -- prepare a new API - - for token operations - - for smart contracts interactions - the the best would be to pass the arguments as is (always requiring ABI without typed helpers ???) - - pass ABI as link to a file or as content or both? - test guardians -- use Knip to detect unused stuff and do the cleanup -- test on the testnet - update README and docs and demos - how it is built now - what it can't do + - why the mobile provider is so big and what can be done to make it smaller, plus why it isn't so bad because it is a separate file +- check TODOs in code +- use Knip to detect unused stuff (in both packages) and do the cleanup +- test on the testnet +- add jsdoc comments for main functions diff --git a/configs/esbuild/index.js b/configs/esbuild/index.js new file mode 100644 index 0000000..2237d17 --- /dev/null +++ b/configs/esbuild/index.js @@ -0,0 +1,26 @@ +const banner = `/*! + * Portions of this code are derived from MultiversX libraries. + * These portions are licensed under the MIT License. + * + * See the MultiversX repository for details: https://github.com/multiversx + * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE + */ +`; + +export const baseConfig = { + format: 'esm', + bundle: true, + metafile: true, + minify: true, + outdir: 'build', + platform: 'browser', + target: ['es2022'], + banner: { js: banner }, + treeShaking: true, + // pure: ['console.log', 'console.info', 'console.debug', 'console.warn'], + sourcemap: false, + define: { + 'process.env.NODE_ENV': '"production"', + global: 'window', + }, +}; diff --git a/configs/esbuild/package.json b/configs/esbuild/package.json new file mode 100644 index 0000000..09080b9 --- /dev/null +++ b/configs/esbuild/package.json @@ -0,0 +1,13 @@ +{ + "name": "@configs/esbuild", + "type": "module", + "private": true, + "main": "index.js", + "devDependencies": { + "esbuild": "0.24.0" + }, + "scripts": { + "lint": "eslint \"**/*.{ts,tsx,js,jsx}\" --fix", + "prettier": "prettier --write '**/*.{js,ts,json}'" + } +} diff --git a/eslint.config.mjs b/configs/eslint-config/index.js similarity index 100% rename from eslint.config.mjs rename to configs/eslint-config/index.js diff --git a/configs/eslint-config/package.json b/configs/eslint-config/package.json new file mode 100644 index 0000000..7e13800 --- /dev/null +++ b/configs/eslint-config/package.json @@ -0,0 +1,19 @@ +{ + "name": "@configs/eslint-config", + "version": "0.0.0", + "type": "module", + "private": true, + "main": "index.js", + "devDependencies": { + "@eslint/eslintrc": "3.2.0", + "@eslint/js": "9.15.0", + "@typescript-eslint/eslint-plugin": "8.14.0", + "@typescript-eslint/parser": "8.14.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1" + }, + "scripts": { + "lint": "eslint \"**/*.{ts,tsx,js,jsx}\" --fix", + "prettier": "prettier --write '**/*.{js,ts,json}'" + } +} \ No newline at end of file diff --git a/configs/tsconfig/base.json b/configs/tsconfig/base.json new file mode 100644 index 0000000..4965c0d --- /dev/null +++ b/configs/tsconfig/base.json @@ -0,0 +1,21 @@ +{ + "include": [ + "src/**/*" + ], + "compilerOptions": { + "strict": true, + "target": "ES2020", + "module": "ES2020", + "declaration": true, + "declarationDir": "./build/types", + "emitDeclarationOnly": true, + "moduleResolution": "Node", + "allowSyntheticDefaultImports": true, + "resolveJsonModule": true, + "types": [ + "node" + ], + "skipLibCheck": true, + "importHelpers": false + } +} \ No newline at end of file diff --git a/configs/tsconfig/package.json b/configs/tsconfig/package.json new file mode 100644 index 0000000..edfdd76 --- /dev/null +++ b/configs/tsconfig/package.json @@ -0,0 +1,8 @@ +{ + "name": "@configs/tsconfig", + "version": "0.0.0", + "private": true, + "files": [ + "base.json" + ] +} \ No newline at end of file diff --git a/example/demo-styles.css b/demo-app/demo-styles.css similarity index 100% rename from example/demo-styles.css rename to demo-app/demo-styles.css diff --git a/example/demo-ui-tools.js b/demo-app/demo-ui-tools.js similarity index 100% rename from example/demo-ui-tools.js rename to demo-app/demo-ui-tools.js diff --git a/demo-app/elven.js b/demo-app/elven.js new file mode 100644 index 0000000..6fb57ce --- /dev/null +++ b/demo-app/elven.js @@ -0,0 +1,11 @@ +/*! + * Portions of this code are derived from MultiversX libraries. + * These portions are licensed under the MIT License. + * + * See the MultiversX repository for details: https://github.com/multiversx + * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE + */ + +var ot=Object.defineProperty;var st=(n,e)=>{for(var t in e)ot(n,t,{get:e[t],enumerable:!0})};var D="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ne=new Uint8Array(256);for(let n=0;n/^[0-9a-fA-F]{64}$/.test(n),L=n=>at.encode(n),N=n=>ct.decode(n),A=n=>{if(!/^[0-9a-fA-F]+$/.test(n)||n.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(n.length/2);for(let t=0;tArray.from(n).map(e=>e.toString(16).padStart(2,"0")).join(""),Ue=n=>b(L(n)),k=n=>{n=n.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;n.endsWith("==")?e=2:n.endsWith("=")&&(e=1);let t=Math.floor(n.length*6/8-e),r=new Uint8Array(t),o=0,i=0,s=0;for(let c=0;c=8&&(i-=8,r[s++]=o>>i&255)}return r},dt=n=>{let e="",t=n.length;for(let r=0;r>18&63,g=c>>12&63,T=c>>6&63,Ie=c&63;e+=D.charAt(l),e+=D.charAt(g),e+=r+1N(k(n)),R=n=>{let e=typeof n=="string"?L(n):n;return dt(e)};function lt(n){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,r;for(;(r=t.exec(n))!==null;)r[1]!==void 0?e.push(r[1]):r[2]!==void 0&&(r[2]===""?e.push(""):/^\d+$/.test(r[2])?e.push(Number(r[2])):e.push(r[2]));return e}function ut(n,e,t){let r=n;for(let o=0;o{he([...n,""],r,t)});else for(let r in e)Object.prototype.hasOwnProperty.call(e,r)&&he([...n,r],e[r],t);else{let r=n.map((o,i)=>i===0?encodeURIComponent(String(o)):o===""?"[]":`[${encodeURIComponent(String(o))}]`).join("");t.push(`${r}=${encodeURIComponent(e)}`)}}function Te(n){let e=new URLSearchParams(n),t={};for(let[r,o]of e.entries()){let i=lt(r);ut(t,i,o)}return t}function ke(n){let e=[];return he([],n,e),e.join("&")}var gt=()=>typeof window<"u"&&typeof window.location<"u",Q=()=>{if(gt()){let n=window.location.ancestorOrigins;return n?.[n.length-1]??"*"}return"*"},we=()=>{let n=window;return!!(n?.ReactNativeWebView||n?.webkit)};var I=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";Oe(e)&&(this.address=A(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:b(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return b(this.address)}};var Me=1e9,We=0,X=2,_e=2,ye=64,De=1;var Fe="sdk-js";var Ge="hook/login",$e="hook/logout";var He="hook/sign",Be="hook/2fa",qe="hook/sign-message",j="walletProviderStatus",Y="transactionsSigned";var ze={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var C=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||Me),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||X),this.options=Number(e.options?.valueOf()||We),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var S=class extends Error{constructor(t,r){super(t);this.inner=void 0;this.inner=r}summary(){let t=[];t.push({name:this.name,message:this.message});let r=this.inner;for(;r;)t.push({name:r.name,message:r.message}),r=r.inner;return t}};var Z=class extends S{constructor(){super("Async timer already running")}},ee=class extends S{constructor(){super("Async timer aborted")}};var F=class extends S{constructor(){super("Expected transaction status not reached")}},K=class extends S{constructor(){super("Expected transaction events not found")}};var te=class extends S{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var ne=class extends S{constructor(){super("Cannot sign single transaction.")}},re=class extends S{constructor(){super("Account is not connected.")}},V=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},ie=class extends Error{constructor(){super("Cannot get signed message")}};var G=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new Z;return this.correlationTag++,new Promise((t,r)=>{this.rejectionFunc=r;let o=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(o,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new ee),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var ve=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},J=class n{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=n.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new ve(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||n.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||n.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||n.DefaultPatience}async awaitPending(e){let t=i=>i.status.isPending(),r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new F;return this.awaitConditionally(t,r,o)}async awaitCompleted(e){let t=i=>{if(i.isCompleted===void 0)throw new te;return i.isCompleted},r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new F;return this.awaitConditionally(t,r,o)}async awaitAllEvents(e,t){let r=s=>{let c=this.getAllTransactionEvents(s).map(g=>g.identifier);return t.every(g=>c.includes(g))},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new K;return this.awaitConditionally(r,o,i)}async awaitAnyEvent(e,t){let r=s=>{let c=this.getAllTransactionEvents(s).map(g=>g.identifier);return t.find(g=>c.includes(g))!=null},o=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},i=()=>new K;return this.awaitConditionally(r,o,i)}async awaitOnCondition(e,t){let r=async()=>{let i=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(i)},o=()=>new F;return this.awaitConditionally(t,r,o)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==ye)throw new S(`Invalid transaction hash length. The length of a hex encoded hash should be ${ye}.`);return t}async awaitConditionally(e,t,r){let o=new G("watcher:periodic"),i=new G("watcher:patience"),s=new G("watcher:timeout"),c=!1,l,g=!1;for(s.start(this.timeoutMilliseconds).finally(()=>{s.stop(),c=!0});!c&&(await o.start(this.pollingIntervalMilliseconds),l=await t(),g=e(l),!(g||c)););if(g&&await i.start(this.patienceMilliseconds),s.isStopped()||s.stop(),!l||!g)throw r();return l}getAllTransactionEvents(e){let t=[...e.logs.events];for(let r of e.contractResults.items)t.push(...r.logs.events);return t}};var x=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||De,this.signer=e.signer||Fe}};var h=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?R(e.senderUsername):void 0,receiverUsername:e.receiverUsername?R(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?R(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?b(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?b(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new C({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:z(e.receiverUsername||""),sender:e.sender,senderUsername:z(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?k(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?A(e.signature):void 0,guardianSignature:e.guardianSignature?A(e.guardianSignature):void 0})}};var M=class n{constructor(){this.account={address:""};this.initialized=!1;if(n._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");n._instance=this}static{this._instance=new n}static getInstance(){return n._instance}setAddress(e){return this.account.address=e,n._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,r=t||"";return await this.startBgrMsgChannel("connect",r),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new ne;return t[0]}ensureConnected(){if(!this.account.address)throw new re}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(r=>h.transactionToPlainObject(r))});try{return t.map(o=>h.plainObjectToTransaction(o))}catch(r){throw new Error(`Transaction canceled: ${r.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:N(e.data)},o=(await this.startBgrMsgChannel("signMessage",t)).signature,i=A(o);return new x({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:i})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(r=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let o=i=>{i.isTrusted&&i.data.target==="erdw-contentScript"&&(i.data.type==="connectResponse"?(i.data.data&&i.data.data.address&&(this.account=i.data.data),window.removeEventListener("message",o),r(i.data.data)):(window.removeEventListener("message",o),r(i.data.data)))};window.addEventListener("message",o,!1)})}};var oe="elvenjs_state",Qe="https://devnet-api.multiversx.com";var O="/dapp/init",se="devnet";var y={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var d={get(n){let e=localStorage.getItem(oe);if(!e)return{};let t=JSON.parse(e);return n?t[n]:t},set(n,e){let t=this.get();t[n]=e,localStorage.setItem(oe,JSON.stringify(t))},clear(){localStorage.removeItem(oe)}};var ae=async()=>{let n=M.getInstance();try{let e=await n.init(),t=d.get();if(t?.address&&n.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return n}catch{console.warn("Can't initialize the Dapp Provider!")}};var be=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},v=class n{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:Ge,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(r=>{setTimeout(()=>{window.location.href=e,r(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:$e,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let r=this.buildWalletUrl({endpoint:qe,callbackUrl:t?.callbackUrl,params:{message:N(e.data)}});return await this.redirect(r),r}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=Te(e);if((t.status?.toString()||"")!=="signed")throw new ie;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(Be,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(He,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=Te(e.slice(1));return n.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,j)&&e[j]===Y}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let i of t)if(!e[i]||!Array.isArray(e[i]))throw new V;let r=e.nonce.length;for(let i of t)if(e[i].length!==r)throw new V;let o=[];for(let i=0;i{let c=n.prepareWalletTransaction(s);for(let l in c)Object.prototype.hasOwnProperty.call(c,l)&&!Object.prototype.hasOwnProperty.call(o,l)&&(o[l]=[]),o[l].push(c[l])});let i=this.buildWalletUrl({endpoint:e,callbackUrl:r?.callbackUrl,params:o});window.location.href=i}};var xe=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*2}},$=class{constructor(e){this.config=Object.assign(new xe,e)}getToken(e,t,r){let o=this.encodeValue(e),i=this.encodeValue(t);return`${o}.${i}.${r}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),r=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${r}`}async getCurrentBlockHash(){return await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(R(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var ce=(n,e)=>t=>{let r=t.data;try{r=we()&&typeof r=="string"?JSON.parse(r):r}catch{console.error("error parsing eventData",r)}let{type:o,payload:i}=r;!we()&&t.origin!=Q()||!(n===o||o==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",ce(n,e)),e({type:o,payload:i}))};var U=class n{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",ce("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:r}=e.payload;if(r||!t)throw new Error("Unable to re-login");let{accessToken:o}=t;return o?(this.account=t,o):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(i=>h.transactionToPlainObject(i))}),{data:r,error:o}=t.payload;if(o||!r)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return r.map(i=>h.plainObjectToTransaction(i))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:N(e.data)}}),{data:r,error:o}=t.payload;return o||!r?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):r.status!=="signed"?(console.error("Could not sign message"),null):new x({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:A(r.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),Q()):t.parent&&t.parent.postMessage(e,Q())),await this.waitingForResponse(ze[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",ce(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return n._instance||(n._instance=new n(e)),n._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var w=n=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(n)}};var Se=async(n,e)=>{let t=w("signature"),r=w("address"),o=d.get("address"),i=d.get("loginToken");if(t&&d.set("signature",t),r||o){r&&(d.set("address",r),window.history.replaceState(null,"",window.location.pathname));let s=new v(`${n}${O}`);if(t&&e&&r){let l=new $({apiUrl:e,origin:window.location.origin}).getToken(r,i,t);d.set("accessToken",l)}return s}};var de=class n{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new n("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var le=class{constructor({apiUrl:e,chainType:t,apiTimeout:r}){this.chainType=t||se,this.apiUrl=e||y[this.chainType]?.apiAddress,this.apiTimeout=r||y[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let r=new AbortController,o=setTimeout(()=>r.abort(),this.apiTimeout),i={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:r.signal};try{let s=await fetch(this.apiUrl+"/"+e,Object.assign(i,t||{})),c=await s.json();if(!s.ok){let l=c?.error||s.status;return clearTimeout(o),Promise.reject(l)}return clearTimeout(o),c}catch(s){this.handleApiError(s,e)}}}async apiPost(e,t,r){if(typeof fetch<"u"){let o=new AbortController,i=setTimeout(()=>o.abort(),this.apiTimeout),s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:o.signal};try{let c=await fetch(this.apiUrl+"/"+e,Object.assign(s,r||{})),l=await c.json();if(!c.ok){let g=l?.error||c.status;return clearTimeout(i),Promise.reject(g)}return clearTimeout(i),l}catch(c){this.handleApiError(c,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let r=e.response.data,o=r.error||r.message||JSON.stringify(r);throw new Error(o)}async sendTransaction(e){let t=h.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),r=new de(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:k(t.data||""),status:r,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!r.isPending()}}async queryContract({address:e,func:t,args:r,value:o,caller:i}){try{let s={scAddress:e,caller:i,funcName:t,value:o,args:()=>r?.map(l=>Ue(l))},c=await this.apiPost("query",s);return{returnData:c.returnData,returnCode:c.returnCode,returnMessage:c.returnMessage}}catch(s){this.handleApiError(s,"query")}}};var E=(m=>(m.onLoginStart="onLoginStart",m.onLoginSuccess="onLoginSuccess",m.onLoginFailure="onLoginFailure",m.onLogoutStart="onLogoutStart",m.onLogoutSuccess="onLogoutSuccess",m.onLogoutFailure="onLogoutFailure",m.onQrPending="onQrPending",m.onQrLoaded="onQrLoaded",m.onTxStart="onTxStart",m.onTxSent="onTxSent",m.onTxFinalized="onTxFinalized",m.onTxFailure="onTxFailure",m.onSignMsgStart="onSignMsgStart",m.onSignMsgFinalized="onSignMsgFinalized",m.onSignMsgFailure="onSignMsgFailure",m.onQueryStart="onQueryStart",m.onQueryFinalized="onQueryFinalized",m.onQueryFailure="onQueryFailure",m))(E||{}),W=(s=>(s.ledger="ledger",s.mobile="mobile",s.webWallet="web-wallet",s.browserExtension="browser-extension",s.xAlias="x-alias",s.webview="webview",s))(W||{}),mt=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(mt||{}),Pe=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(Pe||{});var P={};st(P,{clear:()=>Ae,get:()=>ft,run:()=>u,set:()=>p});var _;function p(n,e){n&&(_={..._,[n]:e})}function ft(n){if(!(!n||!_))return _[n]}function u(n,...e){!n||!_||_[n]?.(...e)}function Ae(){_=void 0}var f=n=>typeof n=="string"?n.toUpperCase():n instanceof Error?n.message:JSON.stringify(n);var Re=async n=>{if(!n.dappProvider)throw new Error("Logout failed: There is no active session!");u("onLogoutStart");try{let e=await n.dappProvider.logout();return e&&(d.clear(),u("onLogoutSuccess")),e}catch(e){let t=f(e);console.warn(`Something went wrong trying to logout the user: ${t}`),u("onLogoutFailure",t)}};var H=()=>new Date().setHours(new Date().getHours()+24),ue=n=>Date.now()>n;var B=async n=>{let e=d.get("address"),t=d.get("expires");if(!(typeof t=="number"?ue(t):!0)&&e&&n.networkProvider){let o=new I(e);try{let i=await n.networkProvider.getAccount(e),s=await n.networkProvider.getGuardianData(e);d.set("address",e),d.set("activeGuardian",s.guarded&&s.activeGuardian?.address?s.activeGuardian.address:""),d.set("nonce",i.nonce.valueOf()),d.set("balance",i.balance.toString()),o.update(i)}catch(i){let s=f(i);console.warn(`Something went wrong trying to synchronize the user account: ${s}`)}}};var je=async(n,e,t,r="/")=>{let o=await ae(),s={callbackUrl:encodeURIComponent(`${window.location.origin}${r}`),token:e};try{if(o&&!await o.login(s))throw new Error("There were problems while logging in!")}catch(g){let T=f(g);throw new Error(T)}if(!o)throw new Error("There were problems with auth provider initialization!");let c=o.getAccount();d.set("loginToken",e);let l=c?.signature;if(l&&d.set("signature",l),n.networkProvider&&l)try{let g=await o.getAddress();if(!g)throw new Error("Canceled!");d.set("address",g),d.set("loginMethod","browser-extension"),d.set("expires",H()),await B(n);let T=t.getToken(g,e,l);return d.set("accessToken",T),u("onLoginSuccess"),o}catch(g){throw new Error(`Something went wrong trying to synchronize the user account: ${g?.message}`)}};var Ee=async(n,e,t,r)=>{let o=new v(`${n}${O}`),s={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${r||"/"}`):"/",token:e};try{return d.set("loginMethod",y[t].xAliasAddress===n?"x-alias":"web-wallet"),await o.login(s),d.set("expires",H()),d.set("loginToken",e),o}catch(c){let l=f(c);console.warn(`Something went wrong trying to login the user: ${l}`),d.set("loginMethod",""),u("onLoginFailure",l)}};var ge=async(n,e)=>{u("onTxSent",n);let r=await new J(e).awaitCompleted(n.txHash),o=r.sender,i=new I(o),s=await e.getAccount(o);i.update(s),d.set("address",i.bech32()),d.set("balance",i.balance),u("onTxFinalized",r)};var pe=n=>{let e=n.sender,t=new I(e),r=n.nonce.valueOf();t.incrementNonce(),d.set("nonce",(r+1n).toString())};var Ke=async(n,e,t,r)=>{if(w(j)===Y&&n&&e){let i=d.get("activeGuardian"),s=d.get("loginMethod"),c=w("hasWebWalletGuardianSign"),l;if("getTransactionsFromWalletUrl"in n){if(l=n.getTransactionsFromWalletUrl()?.[0],!l)return;s==="web-wallet"&&(l.data=R(l.data))}else i&&s!=="web-wallet"&&s!=="x-alias"&&c&&(l=new v(`${t}${O}`).getTransactionsFromWalletUrl()?.[0]);if(l){let g=h.plainObjectToTransaction(l);g.nonce=BigInt(r),pe(g);try{u("onTxStart",g);let T=await e.sendTransaction(g);await ge(T,e)}catch(T){let Le=`Getting transaction information failed! ${f(T)}`;throw u("onTxFailure",g,Le),new Error(Le)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var Ve=n=>{let e=d.get("activeGuardian");return e&&(n.version=X,n.options=_e,n.guardian=e),n},Je=async(n,e)=>{let t=new v(`${e}${O}`),r=window?.location.href,o=new URL(r);o.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([n],{callbackUrl:encodeURIComponent(o.toString())})},Xe=n=>{let e=d.get("activeGuardian");return!(!d.get("address")||!e||n.isGuardedTransaction())};var Ye=()=>{let n=!w("walletProviderStatus"),e=w("status")==="signed",t=w("message"),r=w("signature");n&&e&&t&&r&&(u("onSignMsgFinalized",t,r),window.history.replaceState(null,"",window.location.pathname))};function ht(n){try{let e=atob(n),t=btoa(e),r=z(n),o=R(r),i=n===t||t.startsWith(n),s=n===o||o.startsWith(n);if(i&&s)return!0}catch{return!1}return!1}function q(n){return ht(n)?atob(n):n}var me=n=>Object.prototype.toString.call(n)==="[object String]";var Ze=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==4)return null;try{let[t,r,o,i]=e,s=JSON.parse(q(i)),c=q(t);return{ttl:Number(o),extraInfo:s,origin:c,blockHash:r}}catch(t){return console.error(`Error trying to decode ${n}:`,t),null}};var et=n=>{if(!n||!me(n))return null;let e=n.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,r,o]=e,i=q(t),s=q(r),c=Ze(s);if(!c)return{address:i,body:s,signature:o,blockHash:"",origin:"",ttl:0};let l={...c,address:i,body:s,signature:o};return c.extraInfo?.timestamp||delete l.extraInfo,l}catch{return null}};function tt(n,e){let t=et(n);if(t==null)return;let{signature:r,address:o,body:i}=t;r&&n&&o&&(d.set("loginToken",i),d.set("accessToken",n),d.set("signature",r),d.set("address",o),d.set("loginMethod","webview"),e.dappProvider=new U)}var nt=n=>{n.onLoginStart&&p("onLoginStart",n.onLoginStart),n.onLoginSuccess&&p("onLoginSuccess",n.onLoginSuccess),n.onLoginFailure&&p("onLoginFailure",n.onLoginFailure),n.onLogoutStart&&p("onLogoutStart",n.onLogoutStart),n.onLogoutSuccess&&p("onLogoutSuccess",n.onLogoutSuccess),n.onLogoutFailure&&p("onLogoutFailure",n.onLogoutFailure);let e=n?.externalSigningProviders?.mobile?.config;e?.onQrPending&&p("onQrPending",e.onQrPending),e?.onQrLoaded&&p("onQrLoaded",e.onQrLoaded),n.onTxStart&&p("onTxStart",n.onTxStart),n.onTxSent&&p("onTxSent",n.onTxSent),n.onTxFinalized&&p("onTxFinalized",n.onTxFinalized),n.onTxFailure&&p("onTxFailure",n.onTxFailure),n.onSignMsgStart&&p("onSignMsgStart",n.onSignMsgStart),n.onSignMsgFinalized&&p("onSignMsgFinalized",n.onSignMsgFinalized),n.onSignMsgFailure&&p("onSignMsgFailure",n.onSignMsgFailure),n.onQueryStart&&p("onQueryStart",n.onQueryStart),n.onQueryFinalized&&p("onQueryFinalized",n.onQueryFinalized),n.onQueryFailure&&p("onQueryFailure",n.onQueryFailure)};var fe=async n=>{u("onLoginStart");try{await n(()=>{u("onLoginSuccess")})}catch(e){let t=f(e);console.warn(`Something went wrong trying to login the user: ${t}`),u("onLoginFailure",t)}};var a={initOptions:void 0,dappProvider:void 0,networkProvider:void 0,mobileProvider:void 0},rt=()=>{a.initOptions=void 0,a.dappProvider=void 0,a.networkProvider=void 0,a.mobileProvider=void 0};var Qi=async n=>{let e=d.get();if(e.expires&&ue(e.expires)){d.clear(),a.dappProvider=void 0;return}a.initOptions={chainType:se,apiUrl:Qe,apiTimeout:1e4,...n},a.networkProvider=new le(a.initOptions),nt(a.initOptions);let t=a.initOptions?.externalSigningProviders?.mobile?.provider;if(t){let i={networkConfig:y,Message:x,Transaction:C,TransactionsConverter:h,ls:d,logout:Re,getNewLoginExpiresTimestamp:H,accountSync:B,EventsStore:P},s=a.initOptions?.externalSigningProviders?.mobile?.config;if(s)a.mobileProvider=new t(s,i);else throw new Error("Mobile provider config is required!")}let r=w("accessToken");r&&await fe(async i=>{tt(r,a),await B(a),i()}),(e?.address||(e.loginMethod==="web-wallet"||e.loginMethod==="x-alias")&&w("address"))&&e?.loginMethod&&(await fe(async i=>{e.loginMethod==="browser-extension"&&(a.dappProvider=await ae()),e.loginMethod==="mobile"&&a.mobileProvider&&(a.dappProvider=await a.mobileProvider?.initMobileProvider(a)),e.loginMethod==="webview"&&(a.dappProvider=new U),e.loginMethod==="web-wallet"&&a.initOptions?.chainType&&(a.dappProvider=await Se(y[a.initOptions.chainType].walletAddress,a.initOptions.apiUrl)),e.loginMethod==="x-alias"&&a.initOptions?.chainType&&(a.dappProvider=await Se(y[a.initOptions.chainType].xAliasAddress,a.initOptions.apiUrl)),await B(a),i()}),a.initOptions?.chainType&&(await Ke(a.dappProvider,a.networkProvider,y[a.initOptions.chainType][e.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],e.nonce),Ye()))},ji=async(n,e)=>{if(!Object.values(W).includes(n)){let r="Wrong login method!";throw u("onLoginFailure",r),new Error(r)}if(!a.networkProvider){let r="Login failed: Use ElvenJs.init() first!";throw u("onLoginFailure",r),new Error(r)}await fe(async()=>{let r=new $({apiUrl:a.initOptions?.apiUrl,origin:window.location.origin}),o=await r.initialize({timestamp:`${Math.floor(Date.now()/1e3)}`});if(n==="browser-extension"){let i=await je(a,o,r,e?.callbackRoute);a.dappProvider=i}if(n==="mobile"&&a.mobileProvider){let i=await a.mobileProvider?.loginWithMobile(a,o,r);a.dappProvider=i}if(n==="web-wallet"&&a.initOptions?.chainType){let i=await Ee(y[a.initOptions.chainType].walletAddress,o,a.initOptions?.chainType,e?.callbackRoute);a.dappProvider=i}if(n==="x-alias"&&a.initOptions?.chainType){let i=await Ee(y[a.initOptions.chainType].xAliasAddress,o,a.initOptions?.chainType,e?.callbackRoute);a.dappProvider=i}})},Ki=async()=>{try{let n=await Re(a);return a.dappProvider=void 0,n}catch(n){let e=f(n);console.warn("Something went wrong when logging out: ",e)}},Vi=async n=>{if(!a.dappProvider){let t="Transaction signing failed: There is no active session!";throw u("onTxFailure",n,t),new Error(t)}if(!a.networkProvider){let t="Transaction signing failed: There is no active network provider!";throw u("onTxFailure",n,t),new Error(t)}let e=Ve(n);try{u("onTxStart",n);let t=d.get();if(n.nonce=t.nonce,a.dappProvider instanceof M&&(e=await a.dappProvider.signTransaction(n)),a.mobileProvider&&a.dappProvider instanceof a.mobileProvider.WalletConnectV2Provider&&(e=await a.dappProvider.signTransaction(n)),a.dappProvider instanceof U&&(e=await a.dappProvider.signTransaction(n)),a.dappProvider instanceof v&&await a.dappProvider.signTransaction(n),t.loginMethod!=="web-wallet"&&t.loginMethod!=="x-alias"){let r=Xe(e);if(r||pe(e),r&&a.initOptions?.chainType){await Je(e,y[a.initOptions.chainType].walletAddress);return}let o=await a.networkProvider.sendTransaction(e);await ge(o,a.networkProvider)}}catch(t){let r=f(t);throw u("onTxFailure",e,`Getting transaction information failed! ${r}`),new Error(`Getting transaction information failed! ${r}`)}return e},Ji=async(n,e)=>{if(!a.dappProvider){let r="Message signing failed: There is no active session!";throw u("onSignMsgFailure",n,r),new Error(r)}if(!a.networkProvider){let r="Message signing failed: There is no active network provider!";throw u("onSignMsgFailure",n,r),new Error(r)}let t="";try{if(u("onSignMsgStart",n),a.dappProvider instanceof M){let o=await a.dappProvider.signMessage(new x({data:L(n)}));typeof o!="string"&&o?.signature&&(t=b(o.signature))}if(a.mobileProvider&&a.dappProvider instanceof a.mobileProvider.WalletConnectV2Provider){let o=await a.dappProvider.signMessage(new x({data:L(n)}));typeof o!="string"&&o?.signature&&(t=b(o.signature))}if(a.dappProvider instanceof U){let o=await a.dappProvider.signMessage(new x({data:L(n)}));typeof o!="string"&&o?.signature&&(t=b(o.signature))}if(a.dappProvider instanceof v){let o=s=>encodeURIComponent(s).replace(/[!'()*]/g,c=>`%${c.charCodeAt(0).toString(16).toUpperCase()}`),i=e?.callbackUrl||window.location.origin;await a.dappProvider.signMessage(new x({data:L(n)}),{callbackUrl:encodeURIComponent(`${i}${i.includes("?")?"&":"?"}message=${o(n)}`)})}let r=d.get();return r.loginMethod!=="web-wallet"&&r.loginMethod!=="x-alias"&&u("onSignMsgFinalized",n,t),{message:n,messageSignature:t}}catch(r){let o=f(r);throw u("onSignMsgFailure",n,o),new Error(`Message signing failed! ${o}`)}},Xi=async({address:n,func:e,args:t=[],value:r=0,caller:o})=>{if(!a.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!n||!e)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let i={address:n,func:e,args:t,value:r,caller:o};try{u("onQueryStart",i);let s=await a.networkProvider.queryContract(i);return u("onQueryFinalized",s),s}catch(s){let c=f(s);throw u("onQueryFinalized",i,c),new Error(`Smart contract query failed! ${c}`)}},Yi=d,Zi=()=>{rt(),Ae()};var Tt=({amount:n,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=n.toString().replace(/,/g,""),[r,o=""]=t.split("."),i=r+o.padEnd(e,"0");return i=i.substring(0,r.length+e),BigInt(i)},it=({amount:n,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let r=BigInt(n)<0n,o=BigInt(n).toString();r&&(o=o.slice(1)),o=o.padStart(e+1,"0");let i=o.slice(0,-e),s=o.slice(-e);if(t=5){let g=BigInt("1"+"0".repeat(e-t)),T=BigInt(n)+g;return r&&(T=-T),it({amount:T,decimals:e,rounding:t})}}let c=`${i}.${s.padEnd(t,"0")}`;return c=c.replace(/\.?0+$/,""),r&&(c=`-${c}`),c};export{I as Account,mt as DappCoreWCV2CustomMethodsEnum,E as EventStoreEvents,W as LoginMethodsEnum,C as Transaction,J as TransactionWatcher,Pe as WebWalletUrlParamsEnum,Zi as destroy,it as formatAmount,Qi as init,ji as login,Ki as logout,Tt as parseAmount,Xi as queryContract,Vi as signAndSendTransaction,Ji as signMessage,Yi as storage}; +/** keccak.js https://github.com/adraffy/keccak.js @license MIT */ +/** https://github.com/emn178/js-sha3/blob/master/src/sha3.js @license MIT */ diff --git a/example/index.html b/demo-app/index.html similarity index 91% rename from example/index.html rename to demo-app/index.html index 7526291..17e296f 100644 --- a/example/index.html +++ b/demo-app/index.html @@ -23,7 +23,6 @@ - @@ -169,23 +168,41 @@

Other demos:

// Elven.js tools import { - ElvenJS, + init, + login, + logout, + storage, + signMessage, + signAndSendTransaction, + queryContract, Transaction, parseAmount, } from './elven.js'; + import { MobileSigningProvider } from './mobile-signing-provider.js'; + // Options are the defaults and here only to show all of them // You don't have to add them if you want to use default setup // You can only add your custom callbacks const initElven = async () => { - await ElvenJS.init( + await init( { apiUrl: 'https://devnet-api.multiversx.com', chainType: 'devnet', apiTimeout: 10000, - // Remember to change it. Get yours here: https://cloud.walletconnect.com/sign-in - walletConnectV2ProjectId: 'f502675c63610bfe4454080ac86d70e6', - walletConnectV2RelayAddresses: ['wss://relay.walletconnect.com'], + externalSigningProviders: { + mobile: { + provider: MobileSigningProvider, + config: { + // Remember to change it. Get yours here: https://cloud.walletconnect.com/sign-in + walletConnectV2ProjectId: 'f502675c63610bfe4454080ac86d70e6', + walletConnectV2RelayAddresses: ['wss://relay.walletconnect.com'], + qrCodeContainer: 'qr-code-container', + onQrPending: () => { uiPending(true); }, + onQrLoaded: () => { uiPending(false); }, + } + } + }, // All callbacks are optional // You could also rely on try catch to some extent, but callbacks in one place seems convenient // Login callbacks: @@ -201,9 +218,6 @@

Other demos:

onTxSent: (txOnNetwork) => { const hash = txOnNetwork.txHash; hash && updateTxHashContainer(hash, true); }, onTxFinalized: (tx) => { tx?.hash && updateTxHashContainer(tx.hash); uiPending(false); }, onTxFailure: (tx, error) => { displayError(error); uiPending(false); }, - // Qr code callbacks: - onQrPending: () => { uiPending(true); }, - onQrLoaded: () => { uiPending(false); }, // Signing callbacks: onSignMsgStart: (message) => { uiPending(true); }, onSignMsgFinalized: (message, messageSignature) => { messageSignature && updateOperationResultContainer(`➡️ The signature for "${message}" message:\n${messageSignature}`); uiPending(false); }, @@ -232,7 +246,7 @@

Other demos:

document.getElementById('button-login-extension').addEventListener('click', async () => { try { clearQrCodeContainer(); - await ElvenJS.login('browser-extension'); + await login('browser-extension'); } catch (e) { console.log('Login: Something went wrong, try again!', e?.message); } @@ -241,11 +255,7 @@

Other demos:

document.getElementById('button-login-mobile').addEventListener('click', async () => { clearQrCodeContainer(); try { - await ElvenJS.login('mobile', { - // You can also use the DOM element here: - // qrCodeContainer: document.querySelector('#qr-code-container') - qrCodeContainer: 'qr-code-container', - }); + await login('mobile'); } catch (e) { console.log('Login: Something went wrong, try again!', e?.message); } @@ -254,7 +264,7 @@

Other demos:

document.getElementById('button-login-web').addEventListener('click', async () => { try { clearQrCodeContainer(); - await ElvenJS.login('web-wallet', { + await login('web-wallet', { callbackRoute: '/', }); } catch (e) { @@ -265,7 +275,7 @@

Other demos:

document.getElementById('button-login-x-alias').addEventListener('click', async () => { try { clearQrCodeContainer(); - await ElvenJS.login('x-alias', { + await login('x-alias', { callbackRoute: '/', }); } catch (e) { @@ -275,7 +285,7 @@

Other demos:

document.getElementById('button-logout').addEventListener('click', async () => { try { - const isLoggedOut = await ElvenJS.logout(); + const isLoggedOut = await logout(); } catch (e) { console.error(e.message); } @@ -287,8 +297,8 @@

Other demos:

document.getElementById('button-tx').addEventListener('click', async () => { const demoMessage = 'Transaction demo from Elven.js!'; - const isGuardian = ElvenJS.storage.get('activeGuardian'); - const isXalias = ElvenJS.storage.get('loginMethod') === 'x-alias'; + const isGuardian = storage.get('activeGuardian'); + const isXalias = storage.get('loginMethod') === 'x-alias'; // Additional 50000 when there is an active guardian // See more about gas limit calculation here: https://docs.multiversx.com/developers/gas-and-fees/overview/ const gasLimit = ((isGuardian || isXalias) ? 100000 : 50000) + 1500 * demoMessage.length; @@ -296,17 +306,17 @@

Other demos:

const textEncoder = new TextEncoder(); const tx = new Transaction({ - nonce: ElvenJS.storage.get('nonce'), + nonce: storage.get('nonce'), receiver: egldTransferAddress, gasLimit, chainID: 'D', data: textEncoder.encode(demoMessage), value: parseAmount({ amount: '0.001', decimals: 18 }), - sender: ElvenJS.storage.get('address'), + sender: storage.get('address'), }); try { - await ElvenJS.signAndSendTransaction(tx); + await signAndSendTransaction(tx); } catch (e) { throw new Error(e?.message); } @@ -331,12 +341,12 @@

Other demos:

const tx = factory.createTransactionForESDTTokenTransfer({ receiver: new Address(esdtTransferAddress), - sender: new Address(ElvenJS.storage.get('address')), + sender: new Address(storage.get('address')), tokenTransfers: [tokenTransfer] }); try { - await ElvenJS.signAndSendTransaction(tx); + await signAndSendTransaction(tx); } catch (e) { throw new Error(e?.message); } @@ -348,7 +358,7 @@

Other demos:

document.getElementById('button-mint').addEventListener('click', async () => { const contractAddress = new Address(nftMinterSmartContract); - const isGuardian = ElvenJS.storage.get('activeGuardian'); + const isGuardian = storage.get('activeGuardian'); // Additional 50000 when there is an active guardian // See more about gas limit calculation here: https://docs.multiversx.com/developers/gas-and-fees/overview/ const gasLimit = isGuardian ? 14050000 : 14000000; @@ -358,7 +368,7 @@

Other demos:

}); const tx = factory.createTransactionForExecute({ - sender: new Address(ElvenJS.storage.get('address')), + sender: new Address(storage.get('address')), contract: new Address(contractAddress), function: 'mint', nativeTransferAmount: parseAmount({ amount: '0.01', decimals: 18 }), @@ -367,7 +377,7 @@

Other demos:

}); try { - await ElvenJS.signAndSendTransaction(tx); + await signAndSendTransaction(tx); } catch (e) { throw new Error(e?.message); } @@ -381,10 +391,10 @@

Other demos:

// Read more about the Elven Tools Smart Contract here: https://www.elven.tools/docs/sc-endpoints.html document.getElementById('button-query').addEventListener('click', async () => { try { - await ElvenJS.queryContract({ + await queryContract({ address: new Address(nftMinterSmartContract), func: 'getMintedPerAddressTotal', - args: [new AddressValue(new Address(ElvenJS.storage.get('address')))] + args: [new AddressValue(new Address(storage.get('address')))] }); } catch (e) { throw new Error(e?.message); @@ -393,10 +403,10 @@

Other demos:

// You can sign a single message, use // You will get a message and signature back in the ElvenJS callback function 'onSignMsgFinalized' - // In case of browser extension provider and xPortal you can also get it from ElvenJS.signMessage return + // In case of browser extension provider and xPortal you can also get it from signMessage return document.getElementById('button-sign-message').addEventListener('click', async () => { try { - await ElvenJS.signMessage('ElvenFamily'); + await signMessage('ElvenFamily'); } catch (e) { throw new Error(e?.message); } diff --git a/demo-app/mobile-signing-provider.js b/demo-app/mobile-signing-provider.js new file mode 100644 index 0000000..eac6c71 --- /dev/null +++ b/demo-app/mobile-signing-provider.js @@ -0,0 +1,60 @@ +/*! + * Portions of this code are derived from MultiversX libraries. + * These portions are licensed under the MIT License. + * + * See the MultiversX repository for details: https://github.com/multiversx + * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE + */ + +var _y=Object.create;var Jo=Object.defineProperty;var xy=Object.getOwnPropertyDescriptor;var Ey=Object.getOwnPropertyNames;var Sy=Object.getPrototypeOf,Iy=Object.prototype.hasOwnProperty;var al=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var My=(r,e)=>()=>(r&&(e=r(r=0)),e);var Z=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Dt=(r,e)=>{for(var t in e)Jo(r,t,{get:e[t],enumerable:!0})},Wo=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Ey(e))!Iy.call(r,n)&&n!==t&&Jo(r,n,{get:()=>e[n],enumerable:!(i=xy(e,n))||i.enumerable});return r},qt=(r,e,t)=>(Wo(r,e,"default"),t&&Wo(t,e,"default")),qe=(r,e,t)=>(t=r!=null?_y(Sy(r)):{},Wo(e||!r||!r.__esModule?Jo(t,"default",{value:r,enumerable:!0}):t,r)),qs=r=>Wo(Jo({},"__esModule",{value:!0}),r);var un=Z((BS,uc)=>{"use strict";var qn=typeof Reflect=="object"?Reflect:null,fl=qn&&typeof qn.apply=="function"?qn.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},Yo;qn&&typeof qn.ownKeys=="function"?Yo=qn.ownKeys:Object.getOwnPropertySymbols?Yo=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Yo=function(e){return Object.getOwnPropertyNames(e)};function Ay(r){console&&console.warn&&console.warn(r)}var hl=Number.isNaN||function(e){return e!==e};function Ke(){Ke.init.call(this)}uc.exports=Ke;uc.exports.once=Py;Ke.EventEmitter=Ke;Ke.prototype._events=void 0;Ke.prototype._eventsCount=0;Ke.prototype._maxListeners=void 0;var cl=10;function Xo(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty(Ke,"defaultMaxListeners",{enumerable:!0,get:function(){return cl},set:function(r){if(typeof r!="number"||r<0||hl(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");cl=r}});Ke.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Ke.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||hl(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function ul(r){return r._maxListeners===void 0?Ke.defaultMaxListeners:r._maxListeners}Ke.prototype.getMaxListeners=function(){return ul(this)};Ke.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var f=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw f.context=o,f}var u=s[e];if(u===void 0)return!1;if(typeof u=="function")fl(u,this,t);else for(var c=u.length,b=bl(u,c),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=r,f.type=e,f.count=o.length,Ay(f)}return r}Ke.prototype.addListener=function(e,t){return dl(this,e,t,!1)};Ke.prototype.on=Ke.prototype.addListener;Ke.prototype.prependListener=function(e,t){return dl(this,e,t,!0)};function Ry(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ll(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=Ry.bind(i);return n.listener=t,i.wrapFn=n,n}Ke.prototype.once=function(e,t){return Xo(t),this.on(e,ll(this,e,t)),this};Ke.prototype.prependOnceListener=function(e,t){return Xo(t),this.prependListener(e,ll(this,e,t)),this};Ke.prototype.removeListener=function(e,t){var i,n,s,o,f;if(Xo(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){f=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():Ty(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,f||t)}return this};Ke.prototype.off=Ke.prototype.removeListener;Ke.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function pl(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?Dy(n):bl(n,n.length)}Ke.prototype.listeners=function(e){return pl(this,e,!0)};Ke.prototype.rawListeners=function(e){return pl(this,e,!1)};Ke.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):gl.call(r,e)};Ke.prototype.listenerCount=gl;function gl(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}Ke.prototype.eventNames=function(){return this._eventsCount>0?Yo(this._events):[]};function bl(r,e){for(var t=new Array(e),i=0;ilc,__asyncDelegator:()=>$y,__asyncGenerator:()=>Vy,__asyncValues:()=>Hy,__await:()=>Us,__awaiter:()=>Uy,__classPrivateFieldGet:()=>Yy,__classPrivateFieldSet:()=>Xy,__createBinding:()=>By,__decorate:()=>Ly,__exportStar:()=>ky,__extends:()=>Cy,__generator:()=>zy,__importDefault:()=>Jy,__importStar:()=>Wy,__makeTemplateObject:()=>Gy,__metadata:()=>qy,__param:()=>Fy,__read:()=>ml,__rest:()=>Oy,__spread:()=>Ky,__spreadArrays:()=>jy,__values:()=>pc});function Cy(r,e){dc(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function Oy(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;f--)(o=r[f])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function Fy(r,e){return function(t,i){e(t,i,r)}}function qy(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function Uy(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function f(b){try{c(i.next(b))}catch(v){o(v)}}function u(b){try{c(i.throw(b))}catch(v){o(v)}}function c(b){b.done?s(b.value):n(b.value).then(f,u)}c((i=i.apply(r,e||[])).next())})}function zy(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:f(0),throw:f(1),return:f(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function f(c){return function(b){return u([c,b])}}function u(c){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=c[0]&2?n.return:c[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,c[1])).done)return s;switch(n=0,s&&(c=[c[0]&2,s.value]),c[0]){case 0:case 1:s=c;break;case 4:return t.label++,{value:c[1],done:!1};case 5:t.label++,n=c[1],c=[0];continue;case 7:c=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(c[0]===6||c[0]===2)){t=0;continue}if(c[0]===3&&(!s||c[1]>s[0]&&c[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function ml(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(f){o={error:f}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function Ky(){for(var r=[],e=0;e1||f(S,I)})})}function f(S,I){try{u(i[S](I))}catch(M){v(s[0][3],M)}}function u(S){S.value instanceof Us?Promise.resolve(S.value.v).then(c,b):v(s[0][2],S)}function c(S){f("next",S)}function b(S){f("throw",S)}function v(S,I){S(I),s.shift(),s.length&&f(s[0][0],s[0][1])}}function $y(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Us(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function Hy(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof pc=="function"?pc(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(f,u){o=r[s](o),n(f,u,o.done,o.value)})}}function n(s,o,f,u){Promise.resolve(u).then(function(c){s({value:c,done:f})},o)}}function Gy(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function Wy(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function Jy(r){return r&&r.__esModule?r:{default:r}}function Yy(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function Xy(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var dc,lc,zn=My(()=>{dc=function(r,e){return dc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},dc(r,e)};lc=function(){return lc=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(Zo,"__esModule",{value:!0});Zo.delay=void 0;function Zy(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}Zo.delay=Zy});var wl=Z(Bn=>{"use strict";Object.defineProperty(Bn,"__esModule",{value:!0});Bn.ONE_THOUSAND=Bn.ONE_HUNDRED=void 0;Bn.ONE_HUNDRED=100;Bn.ONE_THOUSAND=1e3});var _l=Z(Q=>{"use strict";Object.defineProperty(Q,"__esModule",{value:!0});Q.ONE_YEAR=Q.FOUR_WEEKS=Q.THREE_WEEKS=Q.TWO_WEEKS=Q.ONE_WEEK=Q.THIRTY_DAYS=Q.SEVEN_DAYS=Q.FIVE_DAYS=Q.THREE_DAYS=Q.ONE_DAY=Q.TWENTY_FOUR_HOURS=Q.TWELVE_HOURS=Q.SIX_HOURS=Q.THREE_HOURS=Q.ONE_HOUR=Q.SIXTY_MINUTES=Q.THIRTY_MINUTES=Q.TEN_MINUTES=Q.FIVE_MINUTES=Q.ONE_MINUTE=Q.SIXTY_SECONDS=Q.THIRTY_SECONDS=Q.TEN_SECONDS=Q.FIVE_SECONDS=Q.ONE_SECOND=void 0;Q.ONE_SECOND=1;Q.FIVE_SECONDS=5;Q.TEN_SECONDS=10;Q.THIRTY_SECONDS=30;Q.SIXTY_SECONDS=60;Q.ONE_MINUTE=Q.SIXTY_SECONDS;Q.FIVE_MINUTES=Q.ONE_MINUTE*5;Q.TEN_MINUTES=Q.ONE_MINUTE*10;Q.THIRTY_MINUTES=Q.ONE_MINUTE*30;Q.SIXTY_MINUTES=Q.ONE_MINUTE*60;Q.ONE_HOUR=Q.SIXTY_MINUTES;Q.THREE_HOURS=Q.ONE_HOUR*3;Q.SIX_HOURS=Q.ONE_HOUR*6;Q.TWELVE_HOURS=Q.ONE_HOUR*12;Q.TWENTY_FOUR_HOURS=Q.ONE_HOUR*24;Q.ONE_DAY=Q.TWENTY_FOUR_HOURS;Q.THREE_DAYS=Q.ONE_DAY*3;Q.FIVE_DAYS=Q.ONE_DAY*5;Q.SEVEN_DAYS=Q.ONE_DAY*7;Q.THIRTY_DAYS=Q.ONE_DAY*30;Q.ONE_WEEK=Q.SEVEN_DAYS;Q.TWO_WEEKS=Q.ONE_WEEK*2;Q.THREE_WEEKS=Q.ONE_WEEK*3;Q.FOUR_WEEKS=Q.ONE_WEEK*4;Q.ONE_YEAR=Q.ONE_DAY*365});var gc=Z(Qo=>{"use strict";Object.defineProperty(Qo,"__esModule",{value:!0});var xl=(zn(),qs(Un));xl.__exportStar(wl(),Qo);xl.__exportStar(_l(),Qo)});var Sl=Z(kn=>{"use strict";Object.defineProperty(kn,"__esModule",{value:!0});kn.fromMiliseconds=kn.toMiliseconds=void 0;var El=gc();function Qy(r){return r*El.ONE_THOUSAND}kn.toMiliseconds=Qy;function e2(r){return Math.floor(r/El.ONE_THOUSAND)}kn.fromMiliseconds=e2});var Ml=Z(ea=>{"use strict";Object.defineProperty(ea,"__esModule",{value:!0});var Il=(zn(),qs(Un));Il.__exportStar(yl(),ea);Il.__exportStar(Sl(),ea)});var Al=Z(zs=>{"use strict";Object.defineProperty(zs,"__esModule",{value:!0});zs.Watch=void 0;var ta=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};zs.Watch=ta;zs.default=ta});var Rl=Z(ra=>{"use strict";Object.defineProperty(ra,"__esModule",{value:!0});ra.IWatch=void 0;var bc=class{};ra.IWatch=bc});var Tl=Z(vc=>{"use strict";Object.defineProperty(vc,"__esModule",{value:!0});var t2=(zn(),qs(Un));t2.__exportStar(Rl(),vc)});var jn=Z(Kn=>{"use strict";Object.defineProperty(Kn,"__esModule",{value:!0});var ia=(zn(),qs(Un));ia.__exportStar(Ml(),Kn);ia.__exportStar(Al(),Kn);ia.__exportStar(Tl(),Kn);ia.__exportStar(gc(),Kn)});var $l=Z((lI,Vl)=>{"use strict";function E2(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}Vl.exports=S2;function S2(r,e,t){var i=t&&t.stringify||E2,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var f=1;f-1?v:0,r.charCodeAt(I+1)){case 100:case 102:if(b>=u||e[b]==null)break;v=u||e[b]==null)break;v=u||e[b]===void 0)break;v",v=I+2,I++;break}c+=i(e[b]),v=I+2,I++;break;case 115:if(b>=u)break;v{"use strict";var Hl=$l();Jl.exports=qr;var Vs=O2().console||{},I2={mapHttpRequest:fa,mapHttpResponse:fa,wrapRequestSerializer:Mc,wrapResponseSerializer:Mc,wrapErrorSerializer:Mc,req:fa,res:fa,err:D2};function M2(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function qr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||Vs;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=M2(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let f=r.level||"info",u=Object.create(t);u.log||(u.log=$s),Object.defineProperty(u,"levelVal",{get:b}),Object.defineProperty(u,"level",{get:v,set:S});let c={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:P2(r)};u.levels=qr.levels,u.level=f,u.setMaxListeners=u.getMaxListeners=u.emit=u.addListener=u.on=u.prependListener=u.once=u.prependOnceListener=u.removeListener=u.removeAllListeners=u.listeners=u.listenerCount=u.eventNames=u.write=u.flush=$s,u.serializers=i,u._serialize=n,u._stdErrSerialize=s,u.child=I,e&&(u._logEvent=Ac());function b(){return this.level==="silent"?1/0:this.levels.values[this.level]}function v(){return this._level}function S(M){if(M!=="silent"&&!this.levels.values[M])throw Error("unknown level "+M);this._level=M,Vn(c,u,"error","log"),Vn(c,u,"fatal","error"),Vn(c,u,"warn","error"),Vn(c,u,"info","log"),Vn(c,u,"debug","log"),Vn(c,u,"trace","log")}function I(M,T){if(!M)throw new Error("missing bindings for child Pino");T=T||{},n&&M.serializers&&(T.serializers=M.serializers);let O=T.serializers;if(n&&O){var P=Object.assign({},i,O),z=r.browser.serialize===!0?Object.keys(P):n;delete M.serializers,ca([M],z,P,this._stdErrSerialize)}function B(U){this._childLevel=(U._childLevel|0)+1,this.error=$n(U,M,"error"),this.fatal=$n(U,M,"fatal"),this.warn=$n(U,M,"warn"),this.info=$n(U,M,"info"),this.debug=$n(U,M,"debug"),this.trace=$n(U,M,"trace"),P&&(this.serializers=P,this._serialize=z),e&&(this._logEvent=Ac([].concat(U._logEvent.bindings,M)))}return B.prototype=this,new B(this)}return u}qr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};qr.stdSerializers=I2;qr.stdTimeFunctions=Object.assign({},{nullTime:Gl,epochTime:Wl,unixTime:N2,isoTime:C2});function Vn(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?$s:n[t]?n[t]:Vs[t]||Vs[i]||$s,A2(r,e,t)}function A2(r,e,t){!r.transmit&&e[t]===$s||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),f=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Vs?Vs:this;for(var u=0;u-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function $n(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(Aa,"__esModule",{value:!0});Aa.BrowserRandomSource=void 0;var e0=65536,Cc=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(Oc,"__esModule",{value:!0});function H2(r){for(var e=0;e{});var r0=Z(Ra=>{"use strict";Object.defineProperty(Ra,"__esModule",{value:!0});Ra.NodeRandomSource=void 0;var G2=Jt(),Fc=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof al<"u"){let e=Lc();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(Ta,"__esModule",{value:!0});Ta.SystemRandomSource=void 0;var W2=t0(),J2=r0(),qc=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new W2.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new J2.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};Ta.SystemRandomSource=qc});var n0=Z(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});function Y2(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Ut.mul=Math.imul||Y2;function X2(r,e){return r+e|0}Ut.add=X2;function Z2(r,e){return r-e|0}Ut.sub=Z2;function Q2(r,e){return r<>>32-e}Ut.rotl=Q2;function e3(r,e){return r<<32-e|r>>>e}Ut.rotr=e3;function t3(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Ut.isInteger=Number.isInteger||t3;Ut.MAX_SAFE_INTEGER=9007199254740991;Ut.isSafeInteger=function(r){return Ut.isInteger(r)&&r>=-Ut.MAX_SAFE_INTEGER&&r<=Ut.MAX_SAFE_INTEGER}});var Hn=Z(Le=>{"use strict";Object.defineProperty(Le,"__esModule",{value:!0});var s0=n0();function r3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Le.readInt16BE=r3;function i3(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Le.readUint16BE=i3;function n3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Le.readInt16LE=n3;function s3(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Le.readUint16LE=s3;function o0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Le.writeUint16BE=o0;Le.writeInt16BE=o0;function a0(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Le.writeUint16LE=a0;Le.writeInt16LE=a0;function Uc(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Le.readInt32BE=Uc;function zc(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Le.readUint32BE=zc;function Bc(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Le.readInt32LE=Bc;function kc(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Le.readUint32LE=kc;function Da(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Le.writeUint32BE=Da;Le.writeInt32BE=Da;function Pa(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Le.writeUint32LE=Pa;Le.writeInt32LE=Pa;function o3(r,e){e===void 0&&(e=0);var t=Uc(r,e),i=Uc(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Le.readInt64BE=o3;function a3(r,e){e===void 0&&(e=0);var t=zc(r,e),i=zc(r,e+4);return t*4294967296+i}Le.readUint64BE=a3;function f3(r,e){e===void 0&&(e=0);var t=Bc(r,e),i=Bc(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Le.readInt64LE=f3;function c3(r,e){e===void 0&&(e=0);var t=kc(r,e),i=kc(r,e+4);return i*4294967296+t}Le.readUint64LE=c3;function f0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Da(r/4294967296>>>0,e,t),Da(r>>>0,e,t+4),e}Le.writeUint64BE=f0;Le.writeInt64BE=f0;function c0(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Pa(r>>>0,e,t),Pa(r/4294967296>>>0,e,t+4),e}Le.writeUint64LE=c0;Le.writeInt64LE=c0;function h3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Le.readUintBE=h3;function u3(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Le.writeUintBE=d3;function l3(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!s0.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(wt,"__esModule",{value:!0});wt.randomStringForEntropy=wt.randomString=wt.randomUint32=wt.randomBytes=wt.defaultRandomSource=void 0;var x3=i0(),E3=Hn(),h0=Jt();wt.defaultRandomSource=new x3.SystemRandomSource;function Kc(r,e=wt.defaultRandomSource){return e.randomBytes(r)}wt.randomBytes=Kc;function S3(r=wt.defaultRandomSource){let e=Kc(4,r),t=(0,E3.readUint32LE)(e);return(0,h0.wipe)(e),t}wt.randomUint32=S3;var u0="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function d0(r,e=u0,t=wt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Kc(Math.ceil(r*256/s),t);for(let f=0;f0;f++){let u=o[f];u{"use strict";Object.defineProperty(fi,"__esModule",{value:!0});var Wn=Hn(),Gn=Jt();fi.DIGEST_LENGTH=64;fi.BLOCK_SIZE=128;var p0=function(){function r(){this.digestLength=fi.DIGEST_LENGTH,this.blockSize=fi.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){Gn.wipe(this._buffer),Gn.wipe(this._tempHi),Gn.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=jc(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){Gn.wipe(e.stateHi),Gn.wipe(e.stateLo),e.buffer&&Gn.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();fi.SHA512=p0;var l0=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function jc(r,e,t,i,n,s,o){for(var f=t[0],u=t[1],c=t[2],b=t[3],v=t[4],S=t[5],I=t[6],M=t[7],T=i[0],O=i[1],P=i[2],z=i[3],B=i[4],U=i[5],j=i[6],H=i[7],L,C,W,D,l,w,p,a;o>=128;){for(var d=0;d<16;d++){var m=8*d+s;r[d]=Wn.readUint32BE(n,m),e[d]=Wn.readUint32BE(n,m+4)}for(var d=0;d<80;d++){var _=f,y=u,h=c,x=b,A=v,g=S,R=I,k=M,E=T,N=O,F=P,q=z,K=B,J=U,$=j,V=H;if(L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(v>>>14|B<<18)^(v>>>18|B<<14)^(B>>>9|v<<23),C=(B>>>14|v<<18)^(B>>>18|v<<14)^(v>>>9|B<<23),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=v&S^~v&I,C=B&U^~B&j,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=l0[d*2],C=l0[d*2+1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=r[d%16],C=e[d%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,W=p&65535|a<<16,D=l&65535|w<<16,L=W,C=D,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=(f>>>28|T<<4)^(T>>>2|f<<30)^(T>>>7|f<<25),C=(T>>>28|f<<4)^(f>>>2|T<<30)^(f>>>7|T<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,L=f&u^f&c^u&c,C=T&O^T&P^O&P,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,k=p&65535|a<<16,V=l&65535|w<<16,L=x,C=q,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=W,C=D,l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,x=p&65535|a<<16,q=l&65535|w<<16,u=_,c=y,b=h,v=x,S=A,I=g,M=R,f=k,O=E,P=N,z=F,B=q,U=K,j=J,H=$,T=V,d%16===15)for(var m=0;m<16;m++)L=r[m],C=e[m],l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=r[(m+9)%16],C=e[(m+9)%16],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+1)%16],D=e[(m+1)%16],L=(W>>>1|D<<31)^(W>>>8|D<<24)^W>>>7,C=(D>>>1|W<<31)^(D>>>8|W<<24)^(D>>>7|W<<25),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,W=r[(m+14)%16],D=e[(m+14)%16],L=(W>>>19|D<<13)^(D>>>29|W<<3)^W>>>6,C=(D>>>19|W<<13)^(W>>>29|D<<3)^(D>>>6|W<<26),l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,r[m]=p&65535|a<<16,e[m]=l&65535|w<<16}L=f,C=T,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[0],C=i[0],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[0]=f=p&65535|a<<16,i[0]=T=l&65535|w<<16,L=u,C=O,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[1],C=i[1],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[1]=u=p&65535|a<<16,i[1]=O=l&65535|w<<16,L=c,C=P,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[2],C=i[2],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[2]=c=p&65535|a<<16,i[2]=P=l&65535|w<<16,L=b,C=z,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[3],C=i[3],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[3]=b=p&65535|a<<16,i[3]=z=l&65535|w<<16,L=v,C=B,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[4],C=i[4],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[4]=v=p&65535|a<<16,i[4]=B=l&65535|w<<16,L=S,C=U,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[5],C=i[5],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[5]=S=p&65535|a<<16,i[5]=U=l&65535|w<<16,L=I,C=j,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[6],C=i[6],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[6]=I=p&65535|a<<16,i[6]=j=l&65535|w<<16,L=M,C=H,l=C&65535,w=C>>>16,p=L&65535,a=L>>>16,L=t[7],C=i[7],l+=C&65535,w+=C>>>16,p+=L&65535,a+=L>>>16,w+=l>>>16,p+=w>>>16,a+=p>>>16,t[7]=M=p&65535|a<<16,i[7]=H=l&65535|w<<16,s+=128,o-=128}return s}function M3(r){var e=new p0;e.update(r);var t=e.digest();return e.clean(),t}fi.hash=M3});var T0=Z(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var A3=Js(),Ys=g0(),w0=Jt();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function te(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,_0(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function x0(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function m0(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Xs(t,r),Xs(i,e),x0(t,i)}function E0(r){let e=new Uint8Array(32);return Xs(e,r),e[0]&1}function N3(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function pn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function bn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function je(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function gn(r,e){je(r,e,e)}function S0(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)gn(t,t),i!==2&&i!==4&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function C3(r,e){let t=te(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)gn(t,t),i!==1&&je(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Gc(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te(),c=te(),b=te();bn(t,r[1],r[0]),bn(b,e[1],e[0]),je(t,t,b),pn(i,r[0],r[1]),pn(b,e[0],e[1]),je(i,i,b),je(n,r[3],e[3]),je(n,n,D3),je(s,r[2],e[2]),pn(s,s,s),bn(o,i,t),bn(f,s,n),pn(u,s,n),pn(c,i,t),je(r[0],o,f),je(r[1],c,u),je(r[2],u,f),je(r[3],o,c)}function y0(r,e,t){for(let i=0;i<4;i++)_0(r[i],e[i],t)}function Jc(r,e){let t=te(),i=te(),n=te();S0(n,e[2]),je(t,e[0],n),je(i,e[1],n),Xs(r,i),r[31]^=E0(t)<<7}function I0(r,e,t){Ri(r[0],Hc),Ri(r[1],Jn),Ri(r[2],Jn),Ri(r[3],Hc);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;y0(r,e,n),Gc(e,r),Gc(r,r),y0(r,e,n)}}function Yc(r,e){let t=[te(),te(),te(),te()];Ri(t[0],b0),Ri(t[1],v0),Ri(t[2],Jn),je(t[3],b0,v0),I0(r,t,e)}function M0(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ys.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[te(),te(),te(),te()];Yc(i,e),Jc(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=M0;function O3(r){let e=(0,A3.randomBytes)(32,r),t=M0(e);return(0,w0.wipe)(e),t}ze.generateKeyPair=O3;function L3(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=L3;var $c=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function A0(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*$c[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*$c[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Wc(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;A0(r,e)}function F3(r,e){let t=new Float64Array(64),i=[te(),te(),te(),te()],n=(0,Ys.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ys.SHA512;o.update(s.subarray(32)),o.update(e);let f=o.digest();o.clean(),Wc(f),Yc(i,f),Jc(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let u=o.digest();Wc(u);for(let c=0;c<32;c++)t[c]=f[c];for(let c=0;c<32;c++)for(let b=0;b<32;b++)t[c+b]+=u[c]*n[b];return A0(s.subarray(32),t),s}ze.sign=F3;function R0(r,e){let t=te(),i=te(),n=te(),s=te(),o=te(),f=te(),u=te();return Ri(r[2],Jn),N3(r[1],e),gn(n,r[1]),je(s,n,T3),bn(n,n,r[2]),pn(s,r[2],s),gn(o,s),gn(f,o),je(u,f,o),je(t,u,n),je(t,t,s),C3(t,t),je(t,t,n),je(t,t,s),je(t,t,s),je(r[0],t,s),gn(i,r[0]),je(i,i,s),m0(i,n)&&je(r[0],r[0],P3),gn(i,r[0]),je(i,i,s),m0(i,n)?-1:(E0(r[0])===e[31]>>7&&bn(r[0],Hc,r[0]),je(r[3],r[0],r[1]),0)}function q3(r,e,t){let i=new Uint8Array(32),n=[te(),te(),te(),te()],s=[te(),te(),te(),te()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(R0(s,r))return!1;let o=new Ys.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let f=o.digest();return Wc(f),I0(n,s,f),Yc(s,t.subarray(32)),Gc(n,s),Jc(i,n),!x0(t,i)}ze.verify=q3;function U3(r){let e=[te(),te(),te(),te()];if(R0(e,r))throw new Error("Ed25519: invalid public key");let t=te(),i=te(),n=e[1];pn(t,Jn,n),bn(i,Jn,n),S0(i,i),je(t,t,i);let s=new Uint8Array(32);return Xs(s,t),s}ze.convertPublicKeyToX25519=U3;function z3(r){let e=(0,Ys.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,w0.wipe)(e),t}ze.convertSecretKeyToX25519=z3});var za=Z(He=>{"use strict";Object.defineProperty(He,"__esModule",{value:!0});He.getLocalStorage=He.getLocalStorageOrThrow=He.getCrypto=He.getCryptoOrThrow=He.getLocation=He.getLocationOrThrow=He.getNavigator=He.getNavigatorOrThrow=He.getDocument=He.getDocumentOrThrow=He.getFromWindowOrThrow=He.getFromWindow=void 0;function yn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}He.getFromWindow=yn;function rs(r){let e=yn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}He.getFromWindowOrThrow=rs;function dw(){return rs("document")}He.getDocumentOrThrow=dw;function lw(){return yn("document")}He.getDocument=lw;function pw(){return rs("navigator")}He.getNavigatorOrThrow=pw;function gw(){return yn("navigator")}He.getNavigator=gw;function bw(){return rs("location")}He.getLocationOrThrow=bw;function vw(){return yn("location")}He.getLocation=vw;function mw(){return rs("crypto")}He.getCryptoOrThrow=mw;function yw(){return yn("crypto")}He.getCrypto=yw;function ww(){return rs("localStorage")}He.getLocalStorageOrThrow=ww;function _w(){return yn("localStorage")}He.getLocalStorage=_w});var gp=Z(Ba=>{"use strict";Object.defineProperty(Ba,"__esModule",{value:!0});Ba.getWindowMetadata=void 0;var pp=za();function xw(){let r,e;try{r=pp.getDocumentOrThrow(),e=pp.getLocationOrThrow()}catch{return null}function t(){let v=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=M.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let P=e.protocol+"//"+e.host;if(O.indexOf("/")===0)P+=O;else{let z=e.pathname.split("/");z.pop();let B=z.join("/");P+=B+"/"+O}S.push(P)}else if(O.indexOf("//")===0){let P=e.protocol+O;S.push(P)}else S.push(O)}}return S}function i(...v){let S=r.getElementsByTagName("meta");for(let I=0;IM.getAttribute(O)).filter(O=>O?v.includes(O):!1);if(T.length&&T){let O=M.getAttribute("content");if(O)return O}}return""}function n(){let v=i("name","og:site_name","og:title","twitter:title");return v||(v=r.title),v}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),f=s(),u=e.origin,c=t();return{description:f,url:u,icons:c,name:o}}Ba.getWindowMetadata=xw});var vp=Z((zM,bp)=>{"use strict";bp.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var xp=Z((BM,_p)=>{"use strict";var wp="%[a-f0-9]{2}",mp=new RegExp("("+wp+")|([^%]+?)","gi"),yp=new RegExp("("+wp+")+","gi");function xh(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],xh(t),xh(i))}function Ew(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(mp)||[],t=1;t{"use strict";Ep.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var Mp=Z((KM,Ip)=>{"use strict";Ip.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Iw=vp(),Mw=xp(),Rp=Sp(),Aw=Mp(),Rw=r=>r==null,Eh=Symbol("encodeFragmentIdentifier");function Tw(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[",n,"]"].join("")]:[...t,[it(e,r),"[",it(n,r),"]=",it(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),"[]"].join("")]:[...t,[it(e,r),"[]=",it(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[it(e,r),":list="].join("")]:[...t,[it(e,r),":list=",it(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[it(t,r),e,it(n,r)].join("")]:[[i,it(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,it(e,r)]:[...t,[it(e,r),"=",it(i,r)].join("")]}}function Dw(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&hi(i,r).includes(r.arrayFormatSeparator);i=o?hi(i,r):i;let f=s||o?i.split(r.arrayFormatSeparator).map(u=>hi(u,r)):i===null?i:hi(i,r);n[t]=f};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&hi(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(f=>hi(f,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Tp(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function it(r,e){return e.encode?e.strict?Iw(r):encodeURIComponent(r):r}function hi(r,e){return e.decode?Mw(r):r}function Dp(r){return Array.isArray(r)?r.sort():typeof r=="object"?Dp(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Pp(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Pw(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Np(r){r=Pp(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Ap(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function Cp(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Tp(e.arrayFormatSeparator);let t=Dw(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=Rp(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:hi(o,e),t(hi(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=Ap(s[o],e);else i[n]=Ap(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=Dp(o):n[s]=o,n},Object.create(null))}Ct.extract=Np;Ct.parse=Cp;Ct.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Tp(e.arrayFormatSeparator);let t=o=>e.skipNull&&Rw(r[o])||e.skipEmptyString&&r[o]==="",i=Tw(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let f=r[o];return f===void 0?"":f===null?it(o,e):Array.isArray(f)?f.length===0&&e.arrayFormat==="bracket-separator"?it(o,e)+"[]":f.reduce(i(o),[]).join("&"):it(o,e)+"="+it(f,e)}).filter(o=>o.length>0).join("&")};Ct.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=Rp(r,"#");return Object.assign({url:t.split("?")[0]||"",query:Cp(Np(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:hi(i,e)}:{})};Ct.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[Eh]:!0},e);let t=Pp(r.url).split("?")[0]||"",i=Ct.extract(r.url),n=Ct.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=Ct.stringify(s,e);o&&(o=`?${o}`);let f=Pw(r.url);return r.fragmentIdentifier&&(f=`#${e[Eh]?it(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${f}`};Ct.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[Eh]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=Ct.parseUrl(r,t);return Ct.stringifyUrl({url:i,query:Aw(n,e),fragmentIdentifier:s},t)};Ct.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return Ct.pick(r,i,t)}});var Lp=Z((VM,ka)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=window:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ka=="object"&&ka.exports,f=typeof define=="function"&&define.amd,u=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",c="0123456789abcdef".split(""),b=[31,7936,2031616,520093696],v=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],M=[0,8,16,24],T=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],P=[128,256],z=["hex","buffer","arrayBuffer","array","digest"],B={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),u&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var U=function(E,N,F){return function(q){return new g(E,N,E).update(q)[F]()}},j=function(E,N,F){return function(q,K){return new g(E,N,K).update(q)[F]()}},H=function(E,N,F){return function(q,K,J,$){return a["cshake"+E].update(q,K,J,$)[F]()}},L=function(E,N,F){return function(q,K,J,$){return a["kmac"+E].update(q,K,J,$)[F]()}},C=function(E,N,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}g.prototype.update=function(E){if(this.finalized)throw new Error(e);var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}for(var q=this.blocks,K=this.byteCount,J=E.length,$=this.blockCount,V=0,ee=this.s,G,Y;V>2]|=E[V]<>2]|=Y<>2]|=(192|Y>>6)<>2]|=(128|Y&63)<=57344?(q[G>>2]|=(224|Y>>12)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<>2]|=(240|Y>>18)<>2]|=(128|Y>>12&63)<>2]|=(128|Y>>6&63)<>2]|=(128|Y&63)<=K){for(this.start=G-K,this.block=q[$],G=0;G<$;++G)ee[G]^=q[G];k(ee),this.reset=!0}else this.start=G}return this},g.prototype.encode=function(E,N){var F=E&255,q=1,K=[F];for(E=E>>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return N?K.push(q):K.unshift(q),this.update(K),K.length},g.prototype.encodeString=function(E){var N,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(u&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!u||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);N=!0}var q=0,K=E.length;if(N)q=K;else for(var J=0;J=57344?q+=3:($=65536+(($&1023)<<10|E.charCodeAt(++J)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},g.prototype.bytepad=function(E,N){for(var F=this.encode(N),q=0;q>2]|=this.padding[N&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],N=1;N>4&15]+c[V&15]+c[V>>12&15]+c[V>>8&15]+c[V>>20&15]+c[V>>16&15]+c[V>>28&15]+c[V>>24&15];J%E===0&&(k(N),K=0)}return q&&(V=N[K],$+=c[V>>4&15]+c[V&15],q>1&&($+=c[V>>12&15]+c[V>>8&15]),q>2&&($+=c[V>>20&15]+c[V>>16&15])),$},g.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,N=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,J=0,$=this.outputBits>>3,V;q?V=new ArrayBuffer(F+1<<2):V=new ArrayBuffer($);for(var ee=new Uint32Array(V);J>8&255,$[V+2]=ee>>16&255,$[V+3]=ee>>24&255;J%E===0&&k(N)}return q&&(V=J<<2,ee=N[K],$[V]=ee&255,q>1&&($[V+1]=ee>>8&255),q>2&&($[V+2]=ee>>16&255)),$};function R(E,N,F){g.call(this,E,N,F)}R.prototype=new g,R.prototype.finalize=function(){return this.encode(this.outputBits,!0),g.prototype.finalize.call(this)};var k=function(E){var N,F,q,K,J,$,V,ee,G,Y,_r,ie,ne,xr,se,oe,Er,ae,fe,Sr,ce,he,Ir,ue,de,Mr,le,pe,Ar,ge,be,Rr,ve,me,Tr,ye,we,Dr,_e,xe,Pr,Ee,Se,Nr,Ie,Me,Cr,Ae,Re,Or,Te,De,Lr,Pe,Ne,nr,Be,ke,jt,Vt,$t,Ht,Gt;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],J=E[1]^E[11]^E[21]^E[31]^E[41],$=E[2]^E[12]^E[22]^E[32]^E[42],V=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],Y=E[6]^E[16]^E[26]^E[36]^E[46],_r=E[7]^E[17]^E[27]^E[37]^E[47],ie=E[8]^E[18]^E[28]^E[38]^E[48],ne=E[9]^E[19]^E[29]^E[39]^E[49],N=ie^($<<1|V>>>31),F=ne^(V<<1|$>>>31),E[0]^=N,E[1]^=F,E[10]^=N,E[11]^=F,E[20]^=N,E[21]^=F,E[30]^=N,E[31]^=F,E[40]^=N,E[41]^=F,N=K^(ee<<1|G>>>31),F=J^(G<<1|ee>>>31),E[2]^=N,E[3]^=F,E[12]^=N,E[13]^=F,E[22]^=N,E[23]^=F,E[32]^=N,E[33]^=F,E[42]^=N,E[43]^=F,N=$^(Y<<1|_r>>>31),F=V^(_r<<1|Y>>>31),E[4]^=N,E[5]^=F,E[14]^=N,E[15]^=F,E[24]^=N,E[25]^=F,E[34]^=N,E[35]^=F,E[44]^=N,E[45]^=F,N=ee^(ie<<1|ne>>>31),F=G^(ne<<1|ie>>>31),E[6]^=N,E[7]^=F,E[16]^=N,E[17]^=F,E[26]^=N,E[27]^=F,E[36]^=N,E[37]^=F,E[46]^=N,E[47]^=F,N=Y^(K<<1|J>>>31),F=_r^(J<<1|K>>>31),E[8]^=N,E[9]^=F,E[18]^=N,E[19]^=F,E[28]^=N,E[29]^=F,E[38]^=N,E[39]^=F,E[48]^=N,E[49]^=F,xr=E[0],se=E[1],Me=E[11]<<4|E[10]>>>28,Cr=E[10]<<4|E[11]>>>28,pe=E[20]<<3|E[21]>>>29,Ar=E[21]<<3|E[20]>>>29,Vt=E[31]<<9|E[30]>>>23,$t=E[30]<<9|E[31]>>>23,Ee=E[40]<<18|E[41]>>>14,Se=E[41]<<18|E[40]>>>14,me=E[2]<<1|E[3]>>>31,Tr=E[3]<<1|E[2]>>>31,oe=E[13]<<12|E[12]>>>20,Er=E[12]<<12|E[13]>>>20,Ae=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,ge=E[33]<<13|E[32]>>>19,be=E[32]<<13|E[33]>>>19,Ht=E[42]<<2|E[43]>>>30,Gt=E[43]<<2|E[42]>>>30,Pe=E[5]<<30|E[4]>>>2,Ne=E[4]<<30|E[5]>>>2,ye=E[14]<<6|E[15]>>>26,we=E[15]<<6|E[14]>>>26,ae=E[25]<<11|E[24]>>>21,fe=E[24]<<11|E[25]>>>21,Or=E[34]<<15|E[35]>>>17,Te=E[35]<<15|E[34]>>>17,Rr=E[45]<<29|E[44]>>>3,ve=E[44]<<29|E[45]>>>3,ue=E[6]<<28|E[7]>>>4,de=E[7]<<28|E[6]>>>4,nr=E[17]<<23|E[16]>>>9,Be=E[16]<<23|E[17]>>>9,Dr=E[26]<<25|E[27]>>>7,_e=E[27]<<25|E[26]>>>7,Sr=E[36]<<21|E[37]>>>11,ce=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Lr=E[46]<<24|E[47]>>>8,Nr=E[8]<<27|E[9]>>>5,Ie=E[9]<<27|E[8]>>>5,Mr=E[18]<<20|E[19]>>>12,le=E[19]<<20|E[18]>>>12,ke=E[29]<<7|E[28]>>>25,jt=E[28]<<7|E[29]>>>25,xe=E[38]<<8|E[39]>>>24,Pr=E[39]<<8|E[38]>>>24,he=E[48]<<14|E[49]>>>18,Ir=E[49]<<14|E[48]>>>18,E[0]=xr^~oe&ae,E[1]=se^~Er&fe,E[10]=ue^~Mr&pe,E[11]=de^~le&Ar,E[20]=me^~ye&Dr,E[21]=Tr^~we&_e,E[30]=Nr^~Me&Ae,E[31]=Ie^~Cr&Re,E[40]=Pe^~nr&ke,E[41]=Ne^~Be&jt,E[2]=oe^~ae&Sr,E[3]=Er^~fe&ce,E[12]=Mr^~pe&ge,E[13]=le^~Ar&be,E[22]=ye^~Dr&xe,E[23]=we^~_e&Pr,E[32]=Me^~Ae&Or,E[33]=Cr^~Re&Te,E[42]=nr^~ke&Vt,E[43]=Be^~jt&$t,E[4]=ae^~Sr&he,E[5]=fe^~ce&Ir,E[14]=pe^~ge&Rr,E[15]=Ar^~be&ve,E[24]=Dr^~xe&Ee,E[25]=_e^~Pr&Se,E[34]=Ae^~Or&De,E[35]=Re^~Te&Lr,E[44]=ke^~Vt&Ht,E[45]=jt^~$t&Gt,E[6]=Sr^~he&xr,E[7]=ce^~Ir&se,E[16]=ge^~Rr&ue,E[17]=be^~ve&de,E[26]=xe^~Ee&me,E[27]=Pr^~Se&Tr,E[36]=Or^~De&Nr,E[37]=Te^~Lr&Ie,E[46]=Vt^~Ht&Pe,E[47]=$t^~Gt&Ne,E[8]=he^~xr&oe,E[9]=Ir^~se&Er,E[18]=Rr^~ue&Mr,E[19]=ve^~de&le,E[28]=Ee^~me&ye,E[29]=Se^~Tr&we,E[38]=De^~Nr&Me,E[39]=Lr^~Ie&Cr,E[48]=Ht^~Pe&nr,E[49]=Gt^~Ne&Be,E[0]^=T[q],E[1]^=T[q+1]};if(o)ka.exports=a;else{for(m=0;m{});var Ph=Z((Gp,Dh)=>{(function(r,e){"use strict";function t(p,a){if(!p)throw new Error(a||"Assertion failed")}function i(p,a){p.super_=a;var d=function(){};d.prototype=a.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,a,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((a==="le"||a==="be")&&(d=a,a=10),this._init(p||0,a||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(a){return a instanceof n?!0:a!==null&&typeof a=="object"&&a.constructor.wordSize===n.wordSize&&Array.isArray(a.words)},n.max=function(a,d){return a.cmp(d)>0?a:d},n.min=function(a,d){return a.cmp(d)<0?a:d},n.prototype._init=function(a,d,m){if(typeof a=="number")return this._initNumber(a,d,m);if(typeof a=="object")return this._initArray(a,d,m);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),a=a.toString().replace(/\s+/g,"");var _=0;a[0]==="-"&&(_++,this.negative=1),_=0;_-=3)h=a[_]|a[_-1]<<8|a[_-2]<<16,this.words[y]|=h<>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);else if(m==="le")for(_=0,y=0;_>>26-x&67108863,x+=24,x>=26&&(x-=26,y++);return this._strip()};function o(p,a){var d=p.charCodeAt(a);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function f(p,a,d){var m=o(p,d);return d-1>=a&&(m|=o(p,d-1)<<4),m}n.prototype._parseHex=function(a,d,m){this.length=Math.ceil((a.length-d)/6),this.words=new Array(this.length);for(var _=0;_=d;_-=2)x=f(a,d,_)<=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8;else{var A=a.length-d;for(_=A%2===0?d+1:d;_=18?(y-=18,h+=1,this.words[h]|=x>>>26):y+=8}this._strip()};function u(p,a,d,m){for(var _=0,y=0,h=Math.min(p.length,d),x=a;x=49?y=A-49+10:A>=17?y=A-17+10:y=A,t(A>=0&&y1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=b}catch{n.prototype.inspect=b}else n.prototype.inspect=b;function b(){return(this.red?""}var v=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(a,d){a=a||10,d=d|0||1;var m;if(a===16||a==="hex"){m="";for(var _=0,y=0,h=0;h>>24-_&16777215,_+=2,_>=26&&(_-=26,h--),y!==0||h!==this.length-1?m=v[6-A.length]+A+m:m=A+m}for(y!==0&&(m=y.toString(16)+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}if(a===(a|0)&&a>=2&&a<=36){var g=S[a],R=I[a];m="";var k=this.clone();for(k.negative=0;!k.isZero();){var E=k.modrn(R).toString(a);k=k.idivn(R),k.isZero()?m=E+m:m=v[g-E.length]+E+m}for(this.isZero()&&(m="0"+m);m.length%d!==0;)m="0"+m;return this.negative!==0&&(m="-"+m),m}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var a=this.words[0];return this.length===2?a+=this.words[1]*67108864:this.length===3&&this.words[2]===1?a+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-a:a},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(a,d){return this.toArrayLike(s,a,d)}),n.prototype.toArray=function(a,d){return this.toArrayLike(Array,a,d)};var M=function(a,d){return a.allocUnsafe?a.allocUnsafe(d):new a(d)};n.prototype.toArrayLike=function(a,d,m){this._strip();var _=this.byteLength(),y=m||Math.max(1,_);t(_<=y,"byte array longer than desired length"),t(y>0,"Requested array length <= 0");var h=M(a,y),x=d==="le"?"LE":"BE";return this["_toArrayLike"+x](h,_),h},n.prototype._toArrayLikeLE=function(a,d){for(var m=0,_=0,y=0,h=0;y>8&255),m>16&255),h===6?(m>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m=0&&(a[m--]=x>>8&255),m>=0&&(a[m--]=x>>16&255),h===6?(m>=0&&(a[m--]=x>>24&255),_=0,h=0):(_=x>>>24,h+=2)}if(m>=0)for(a[m--]=_;m>=0;)a[m--]=0},Math.clz32?n.prototype._countBits=function(a){return 32-Math.clz32(a)}:n.prototype._countBits=function(a){var d=a,m=0;return d>=4096&&(m+=13,d>>>=13),d>=64&&(m+=7,d>>>=7),d>=8&&(m+=4,d>>>=4),d>=2&&(m+=2,d>>>=2),m+d},n.prototype._zeroBits=function(a){if(a===0)return 26;var d=a,m=0;return d&8191||(m+=13,d>>>=13),d&127||(m+=7,d>>>=7),d&15||(m+=4,d>>>=4),d&3||(m+=2,d>>>=2),d&1||m++,m},n.prototype.bitLength=function(){var a=this.words[this.length-1],d=this._countBits(a);return(this.length-1)*26+d};function T(p){for(var a=new Array(p.bitLength()),d=0;d>>_&1}return a}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var a=0,d=0;da.length?this.clone().ior(a):a.clone().ior(this)},n.prototype.uor=function(a){return this.length>a.length?this.clone().iuor(a):a.clone().iuor(this)},n.prototype.iuand=function(a){var d;this.length>a.length?d=a:d=this;for(var m=0;ma.length?this.clone().iand(a):a.clone().iand(this)},n.prototype.uand=function(a){return this.length>a.length?this.clone().iuand(a):a.clone().iuand(this)},n.prototype.iuxor=function(a){var d,m;this.length>a.length?(d=this,m=a):(d=a,m=this);for(var _=0;_a.length?this.clone().ixor(a):a.clone().ixor(this)},n.prototype.uxor=function(a){return this.length>a.length?this.clone().iuxor(a):a.clone().iuxor(this)},n.prototype.inotn=function(a){t(typeof a=="number"&&a>=0);var d=Math.ceil(a/26)|0,m=a%26;this._expand(d),m>0&&d--;for(var _=0;_0&&(this.words[_]=~this.words[_]&67108863>>26-m),this._strip()},n.prototype.notn=function(a){return this.clone().inotn(a)},n.prototype.setn=function(a,d){t(typeof a=="number"&&a>=0);var m=a/26|0,_=a%26;return this._expand(m+1),d?this.words[m]=this.words[m]|1<<_:this.words[m]=this.words[m]&~(1<<_),this._strip()},n.prototype.iadd=function(a){var d;if(this.negative!==0&&a.negative===0)return this.negative=0,d=this.isub(a),this.negative^=1,this._normSign();if(this.negative===0&&a.negative!==0)return a.negative=0,d=this.isub(a),a.negative=1,d._normSign();var m,_;this.length>a.length?(m=this,_=a):(m=a,_=this);for(var y=0,h=0;h<_.length;h++)d=(m.words[h]|0)+(_.words[h]|0)+y,this.words[h]=d&67108863,y=d>>>26;for(;y!==0&&h>>26;if(this.length=m.length,y!==0)this.words[this.length]=y,this.length++;else if(m!==this)for(;ha.length?this.clone().iadd(a):a.clone().iadd(this)},n.prototype.isub=function(a){if(a.negative!==0){a.negative=0;var d=this.iadd(a);return a.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(a),this.negative=1,this._normSign();var m=this.cmp(a);if(m===0)return this.negative=0,this.length=1,this.words[0]=0,this;var _,y;m>0?(_=this,y=a):(_=a,y=this);for(var h=0,x=0;x>26,this.words[x]=d&67108863;for(;h!==0&&x<_.length;x++)d=(_.words[x]|0)+h,h=d>>26,this.words[x]=d&67108863;if(h===0&&x<_.length&&_!==this)for(;x<_.length;x++)this.words[x]=_.words[x];return this.length=Math.max(this.length,x),_!==this&&(this.negative=1),this._strip()},n.prototype.sub=function(a){return this.clone().isub(a)};function O(p,a,d){d.negative=a.negative^p.negative;var m=p.length+a.length|0;d.length=m,m=m-1|0;var _=p.words[0]|0,y=a.words[0]|0,h=_*y,x=h&67108863,A=h/67108864|0;d.words[0]=x;for(var g=1;g>>26,k=A&67108863,E=Math.min(g,a.length-1),N=Math.max(0,g-p.length+1);N<=E;N++){var F=g-N|0;_=p.words[F]|0,y=a.words[N]|0,h=_*y+k,R+=h/67108864|0,k=h&67108863}d.words[g]=k|0,A=R|0}return A!==0?d.words[g]=A|0:d.length--,d._strip()}var P=function(a,d,m){var _=a.words,y=d.words,h=m.words,x=0,A,g,R,k=_[0]|0,E=k&8191,N=k>>>13,F=_[1]|0,q=F&8191,K=F>>>13,J=_[2]|0,$=J&8191,V=J>>>13,ee=_[3]|0,G=ee&8191,Y=ee>>>13,_r=_[4]|0,ie=_r&8191,ne=_r>>>13,xr=_[5]|0,se=xr&8191,oe=xr>>>13,Er=_[6]|0,ae=Er&8191,fe=Er>>>13,Sr=_[7]|0,ce=Sr&8191,he=Sr>>>13,Ir=_[8]|0,ue=Ir&8191,de=Ir>>>13,Mr=_[9]|0,le=Mr&8191,pe=Mr>>>13,Ar=y[0]|0,ge=Ar&8191,be=Ar>>>13,Rr=y[1]|0,ve=Rr&8191,me=Rr>>>13,Tr=y[2]|0,ye=Tr&8191,we=Tr>>>13,Dr=y[3]|0,_e=Dr&8191,xe=Dr>>>13,Pr=y[4]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=y[5]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=y[6]|0,Ae=Cr&8191,Re=Cr>>>13,Or=y[7]|0,Te=Or&8191,De=Or>>>13,Lr=y[8]|0,Pe=Lr&8191,Ne=Lr>>>13,nr=y[9]|0,Be=nr&8191,ke=nr>>>13;m.negative=a.negative^d.negative,m.length=19,A=Math.imul(E,ge),g=Math.imul(E,be),g=g+Math.imul(N,ge)|0,R=Math.imul(N,be);var jt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(jt>>>26)|0,jt&=67108863,A=Math.imul(q,ge),g=Math.imul(q,be),g=g+Math.imul(K,ge)|0,R=Math.imul(K,be),A=A+Math.imul(E,ve)|0,g=g+Math.imul(E,me)|0,g=g+Math.imul(N,ve)|0,R=R+Math.imul(N,me)|0;var Vt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,A=Math.imul($,ge),g=Math.imul($,be),g=g+Math.imul(V,ge)|0,R=Math.imul(V,be),A=A+Math.imul(q,ve)|0,g=g+Math.imul(q,me)|0,g=g+Math.imul(K,ve)|0,R=R+Math.imul(K,me)|0,A=A+Math.imul(E,ye)|0,g=g+Math.imul(E,we)|0,g=g+Math.imul(N,ye)|0,R=R+Math.imul(N,we)|0;var $t=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+($t>>>26)|0,$t&=67108863,A=Math.imul(G,ge),g=Math.imul(G,be),g=g+Math.imul(Y,ge)|0,R=Math.imul(Y,be),A=A+Math.imul($,ve)|0,g=g+Math.imul($,me)|0,g=g+Math.imul(V,ve)|0,R=R+Math.imul(V,me)|0,A=A+Math.imul(q,ye)|0,g=g+Math.imul(q,we)|0,g=g+Math.imul(K,ye)|0,R=R+Math.imul(K,we)|0,A=A+Math.imul(E,_e)|0,g=g+Math.imul(E,xe)|0,g=g+Math.imul(N,_e)|0,R=R+Math.imul(N,xe)|0;var Ht=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,A=Math.imul(ie,ge),g=Math.imul(ie,be),g=g+Math.imul(ne,ge)|0,R=Math.imul(ne,be),A=A+Math.imul(G,ve)|0,g=g+Math.imul(G,me)|0,g=g+Math.imul(Y,ve)|0,R=R+Math.imul(Y,me)|0,A=A+Math.imul($,ye)|0,g=g+Math.imul($,we)|0,g=g+Math.imul(V,ye)|0,R=R+Math.imul(V,we)|0,A=A+Math.imul(q,_e)|0,g=g+Math.imul(q,xe)|0,g=g+Math.imul(K,_e)|0,R=R+Math.imul(K,xe)|0,A=A+Math.imul(E,Ee)|0,g=g+Math.imul(E,Se)|0,g=g+Math.imul(N,Ee)|0,R=R+Math.imul(N,Se)|0;var Gt=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,A=Math.imul(se,ge),g=Math.imul(se,be),g=g+Math.imul(oe,ge)|0,R=Math.imul(oe,be),A=A+Math.imul(ie,ve)|0,g=g+Math.imul(ie,me)|0,g=g+Math.imul(ne,ve)|0,R=R+Math.imul(ne,me)|0,A=A+Math.imul(G,ye)|0,g=g+Math.imul(G,we)|0,g=g+Math.imul(Y,ye)|0,R=R+Math.imul(Y,we)|0,A=A+Math.imul($,_e)|0,g=g+Math.imul($,xe)|0,g=g+Math.imul(V,_e)|0,R=R+Math.imul(V,xe)|0,A=A+Math.imul(q,Ee)|0,g=g+Math.imul(q,Se)|0,g=g+Math.imul(K,Ee)|0,R=R+Math.imul(K,Se)|0,A=A+Math.imul(E,Ie)|0,g=g+Math.imul(E,Me)|0,g=g+Math.imul(N,Ie)|0,R=R+Math.imul(N,Me)|0;var Qi=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,A=Math.imul(ae,ge),g=Math.imul(ae,be),g=g+Math.imul(fe,ge)|0,R=Math.imul(fe,be),A=A+Math.imul(se,ve)|0,g=g+Math.imul(se,me)|0,g=g+Math.imul(oe,ve)|0,R=R+Math.imul(oe,me)|0,A=A+Math.imul(ie,ye)|0,g=g+Math.imul(ie,we)|0,g=g+Math.imul(ne,ye)|0,R=R+Math.imul(ne,we)|0,A=A+Math.imul(G,_e)|0,g=g+Math.imul(G,xe)|0,g=g+Math.imul(Y,_e)|0,R=R+Math.imul(Y,xe)|0,A=A+Math.imul($,Ee)|0,g=g+Math.imul($,Se)|0,g=g+Math.imul(V,Ee)|0,R=R+Math.imul(V,Se)|0,A=A+Math.imul(q,Ie)|0,g=g+Math.imul(q,Me)|0,g=g+Math.imul(K,Ie)|0,R=R+Math.imul(K,Me)|0,A=A+Math.imul(E,Ae)|0,g=g+Math.imul(E,Re)|0,g=g+Math.imul(N,Ae)|0,R=R+Math.imul(N,Re)|0;var en=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(en>>>26)|0,en&=67108863,A=Math.imul(ce,ge),g=Math.imul(ce,be),g=g+Math.imul(he,ge)|0,R=Math.imul(he,be),A=A+Math.imul(ae,ve)|0,g=g+Math.imul(ae,me)|0,g=g+Math.imul(fe,ve)|0,R=R+Math.imul(fe,me)|0,A=A+Math.imul(se,ye)|0,g=g+Math.imul(se,we)|0,g=g+Math.imul(oe,ye)|0,R=R+Math.imul(oe,we)|0,A=A+Math.imul(ie,_e)|0,g=g+Math.imul(ie,xe)|0,g=g+Math.imul(ne,_e)|0,R=R+Math.imul(ne,xe)|0,A=A+Math.imul(G,Ee)|0,g=g+Math.imul(G,Se)|0,g=g+Math.imul(Y,Ee)|0,R=R+Math.imul(Y,Se)|0,A=A+Math.imul($,Ie)|0,g=g+Math.imul($,Me)|0,g=g+Math.imul(V,Ie)|0,R=R+Math.imul(V,Me)|0,A=A+Math.imul(q,Ae)|0,g=g+Math.imul(q,Re)|0,g=g+Math.imul(K,Ae)|0,R=R+Math.imul(K,Re)|0,A=A+Math.imul(E,Te)|0,g=g+Math.imul(E,De)|0,g=g+Math.imul(N,Te)|0,R=R+Math.imul(N,De)|0;var tn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(tn>>>26)|0,tn&=67108863,A=Math.imul(ue,ge),g=Math.imul(ue,be),g=g+Math.imul(de,ge)|0,R=Math.imul(de,be),A=A+Math.imul(ce,ve)|0,g=g+Math.imul(ce,me)|0,g=g+Math.imul(he,ve)|0,R=R+Math.imul(he,me)|0,A=A+Math.imul(ae,ye)|0,g=g+Math.imul(ae,we)|0,g=g+Math.imul(fe,ye)|0,R=R+Math.imul(fe,we)|0,A=A+Math.imul(se,_e)|0,g=g+Math.imul(se,xe)|0,g=g+Math.imul(oe,_e)|0,R=R+Math.imul(oe,xe)|0,A=A+Math.imul(ie,Ee)|0,g=g+Math.imul(ie,Se)|0,g=g+Math.imul(ne,Ee)|0,R=R+Math.imul(ne,Se)|0,A=A+Math.imul(G,Ie)|0,g=g+Math.imul(G,Me)|0,g=g+Math.imul(Y,Ie)|0,R=R+Math.imul(Y,Me)|0,A=A+Math.imul($,Ae)|0,g=g+Math.imul($,Re)|0,g=g+Math.imul(V,Ae)|0,R=R+Math.imul(V,Re)|0,A=A+Math.imul(q,Te)|0,g=g+Math.imul(q,De)|0,g=g+Math.imul(K,Te)|0,R=R+Math.imul(K,De)|0,A=A+Math.imul(E,Pe)|0,g=g+Math.imul(E,Ne)|0,g=g+Math.imul(N,Pe)|0,R=R+Math.imul(N,Ne)|0;var rn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(rn>>>26)|0,rn&=67108863,A=Math.imul(le,ge),g=Math.imul(le,be),g=g+Math.imul(pe,ge)|0,R=Math.imul(pe,be),A=A+Math.imul(ue,ve)|0,g=g+Math.imul(ue,me)|0,g=g+Math.imul(de,ve)|0,R=R+Math.imul(de,me)|0,A=A+Math.imul(ce,ye)|0,g=g+Math.imul(ce,we)|0,g=g+Math.imul(he,ye)|0,R=R+Math.imul(he,we)|0,A=A+Math.imul(ae,_e)|0,g=g+Math.imul(ae,xe)|0,g=g+Math.imul(fe,_e)|0,R=R+Math.imul(fe,xe)|0,A=A+Math.imul(se,Ee)|0,g=g+Math.imul(se,Se)|0,g=g+Math.imul(oe,Ee)|0,R=R+Math.imul(oe,Se)|0,A=A+Math.imul(ie,Ie)|0,g=g+Math.imul(ie,Me)|0,g=g+Math.imul(ne,Ie)|0,R=R+Math.imul(ne,Me)|0,A=A+Math.imul(G,Ae)|0,g=g+Math.imul(G,Re)|0,g=g+Math.imul(Y,Ae)|0,R=R+Math.imul(Y,Re)|0,A=A+Math.imul($,Te)|0,g=g+Math.imul($,De)|0,g=g+Math.imul(V,Te)|0,R=R+Math.imul(V,De)|0,A=A+Math.imul(q,Pe)|0,g=g+Math.imul(q,Ne)|0,g=g+Math.imul(K,Pe)|0,R=R+Math.imul(K,Ne)|0,A=A+Math.imul(E,Be)|0,g=g+Math.imul(E,ke)|0,g=g+Math.imul(N,Be)|0,R=R+Math.imul(N,ke)|0;var nn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(nn>>>26)|0,nn&=67108863,A=Math.imul(le,ve),g=Math.imul(le,me),g=g+Math.imul(pe,ve)|0,R=Math.imul(pe,me),A=A+Math.imul(ue,ye)|0,g=g+Math.imul(ue,we)|0,g=g+Math.imul(de,ye)|0,R=R+Math.imul(de,we)|0,A=A+Math.imul(ce,_e)|0,g=g+Math.imul(ce,xe)|0,g=g+Math.imul(he,_e)|0,R=R+Math.imul(he,xe)|0,A=A+Math.imul(ae,Ee)|0,g=g+Math.imul(ae,Se)|0,g=g+Math.imul(fe,Ee)|0,R=R+Math.imul(fe,Se)|0,A=A+Math.imul(se,Ie)|0,g=g+Math.imul(se,Me)|0,g=g+Math.imul(oe,Ie)|0,R=R+Math.imul(oe,Me)|0,A=A+Math.imul(ie,Ae)|0,g=g+Math.imul(ie,Re)|0,g=g+Math.imul(ne,Ae)|0,R=R+Math.imul(ne,Re)|0,A=A+Math.imul(G,Te)|0,g=g+Math.imul(G,De)|0,g=g+Math.imul(Y,Te)|0,R=R+Math.imul(Y,De)|0,A=A+Math.imul($,Pe)|0,g=g+Math.imul($,Ne)|0,g=g+Math.imul(V,Pe)|0,R=R+Math.imul(V,Ne)|0,A=A+Math.imul(q,Be)|0,g=g+Math.imul(q,ke)|0,g=g+Math.imul(K,Be)|0,R=R+Math.imul(K,ke)|0;var sn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(sn>>>26)|0,sn&=67108863,A=Math.imul(le,ye),g=Math.imul(le,we),g=g+Math.imul(pe,ye)|0,R=Math.imul(pe,we),A=A+Math.imul(ue,_e)|0,g=g+Math.imul(ue,xe)|0,g=g+Math.imul(de,_e)|0,R=R+Math.imul(de,xe)|0,A=A+Math.imul(ce,Ee)|0,g=g+Math.imul(ce,Se)|0,g=g+Math.imul(he,Ee)|0,R=R+Math.imul(he,Se)|0,A=A+Math.imul(ae,Ie)|0,g=g+Math.imul(ae,Me)|0,g=g+Math.imul(fe,Ie)|0,R=R+Math.imul(fe,Me)|0,A=A+Math.imul(se,Ae)|0,g=g+Math.imul(se,Re)|0,g=g+Math.imul(oe,Ae)|0,R=R+Math.imul(oe,Re)|0,A=A+Math.imul(ie,Te)|0,g=g+Math.imul(ie,De)|0,g=g+Math.imul(ne,Te)|0,R=R+Math.imul(ne,De)|0,A=A+Math.imul(G,Pe)|0,g=g+Math.imul(G,Ne)|0,g=g+Math.imul(Y,Pe)|0,R=R+Math.imul(Y,Ne)|0,A=A+Math.imul($,Be)|0,g=g+Math.imul($,ke)|0,g=g+Math.imul(V,Be)|0,R=R+Math.imul(V,ke)|0;var on=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(on>>>26)|0,on&=67108863,A=Math.imul(le,_e),g=Math.imul(le,xe),g=g+Math.imul(pe,_e)|0,R=Math.imul(pe,xe),A=A+Math.imul(ue,Ee)|0,g=g+Math.imul(ue,Se)|0,g=g+Math.imul(de,Ee)|0,R=R+Math.imul(de,Se)|0,A=A+Math.imul(ce,Ie)|0,g=g+Math.imul(ce,Me)|0,g=g+Math.imul(he,Ie)|0,R=R+Math.imul(he,Me)|0,A=A+Math.imul(ae,Ae)|0,g=g+Math.imul(ae,Re)|0,g=g+Math.imul(fe,Ae)|0,R=R+Math.imul(fe,Re)|0,A=A+Math.imul(se,Te)|0,g=g+Math.imul(se,De)|0,g=g+Math.imul(oe,Te)|0,R=R+Math.imul(oe,De)|0,A=A+Math.imul(ie,Pe)|0,g=g+Math.imul(ie,Ne)|0,g=g+Math.imul(ne,Pe)|0,R=R+Math.imul(ne,Ne)|0,A=A+Math.imul(G,Be)|0,g=g+Math.imul(G,ke)|0,g=g+Math.imul(Y,Be)|0,R=R+Math.imul(Y,ke)|0;var an=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(an>>>26)|0,an&=67108863,A=Math.imul(le,Ee),g=Math.imul(le,Se),g=g+Math.imul(pe,Ee)|0,R=Math.imul(pe,Se),A=A+Math.imul(ue,Ie)|0,g=g+Math.imul(ue,Me)|0,g=g+Math.imul(de,Ie)|0,R=R+Math.imul(de,Me)|0,A=A+Math.imul(ce,Ae)|0,g=g+Math.imul(ce,Re)|0,g=g+Math.imul(he,Ae)|0,R=R+Math.imul(he,Re)|0,A=A+Math.imul(ae,Te)|0,g=g+Math.imul(ae,De)|0,g=g+Math.imul(fe,Te)|0,R=R+Math.imul(fe,De)|0,A=A+Math.imul(se,Pe)|0,g=g+Math.imul(se,Ne)|0,g=g+Math.imul(oe,Pe)|0,R=R+Math.imul(oe,Ne)|0,A=A+Math.imul(ie,Be)|0,g=g+Math.imul(ie,ke)|0,g=g+Math.imul(ne,Be)|0,R=R+Math.imul(ne,ke)|0;var fn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fn>>>26)|0,fn&=67108863,A=Math.imul(le,Ie),g=Math.imul(le,Me),g=g+Math.imul(pe,Ie)|0,R=Math.imul(pe,Me),A=A+Math.imul(ue,Ae)|0,g=g+Math.imul(ue,Re)|0,g=g+Math.imul(de,Ae)|0,R=R+Math.imul(de,Re)|0,A=A+Math.imul(ce,Te)|0,g=g+Math.imul(ce,De)|0,g=g+Math.imul(he,Te)|0,R=R+Math.imul(he,De)|0,A=A+Math.imul(ae,Pe)|0,g=g+Math.imul(ae,Ne)|0,g=g+Math.imul(fe,Pe)|0,R=R+Math.imul(fe,Ne)|0,A=A+Math.imul(se,Be)|0,g=g+Math.imul(se,ke)|0,g=g+Math.imul(oe,Be)|0,R=R+Math.imul(oe,ke)|0;var cn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cn>>>26)|0,cn&=67108863,A=Math.imul(le,Ae),g=Math.imul(le,Re),g=g+Math.imul(pe,Ae)|0,R=Math.imul(pe,Re),A=A+Math.imul(ue,Te)|0,g=g+Math.imul(ue,De)|0,g=g+Math.imul(de,Te)|0,R=R+Math.imul(de,De)|0,A=A+Math.imul(ce,Pe)|0,g=g+Math.imul(ce,Ne)|0,g=g+Math.imul(he,Pe)|0,R=R+Math.imul(he,Ne)|0,A=A+Math.imul(ae,Be)|0,g=g+Math.imul(ae,ke)|0,g=g+Math.imul(fe,Be)|0,R=R+Math.imul(fe,ke)|0;var hn=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(hn>>>26)|0,hn&=67108863,A=Math.imul(le,Te),g=Math.imul(le,De),g=g+Math.imul(pe,Te)|0,R=Math.imul(pe,De),A=A+Math.imul(ue,Pe)|0,g=g+Math.imul(ue,Ne)|0,g=g+Math.imul(de,Pe)|0,R=R+Math.imul(de,Ne)|0,A=A+Math.imul(ce,Be)|0,g=g+Math.imul(ce,ke)|0,g=g+Math.imul(he,Be)|0,R=R+Math.imul(he,ke)|0;var fc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(fc>>>26)|0,fc&=67108863,A=Math.imul(le,Pe),g=Math.imul(le,Ne),g=g+Math.imul(pe,Pe)|0,R=Math.imul(pe,Ne),A=A+Math.imul(ue,Be)|0,g=g+Math.imul(ue,ke)|0,g=g+Math.imul(de,Be)|0,R=R+Math.imul(de,ke)|0;var cc=(x+A|0)+((g&8191)<<13)|0;x=(R+(g>>>13)|0)+(cc>>>26)|0,cc&=67108863,A=Math.imul(le,Be),g=Math.imul(le,ke),g=g+Math.imul(pe,Be)|0,R=Math.imul(pe,ke);var hc=(x+A|0)+((g&8191)<<13)|0;return x=(R+(g>>>13)|0)+(hc>>>26)|0,hc&=67108863,h[0]=jt,h[1]=Vt,h[2]=$t,h[3]=Ht,h[4]=Gt,h[5]=Qi,h[6]=en,h[7]=tn,h[8]=rn,h[9]=nn,h[10]=sn,h[11]=on,h[12]=an,h[13]=fn,h[14]=cn,h[15]=hn,h[16]=fc,h[17]=cc,h[18]=hc,x!==0&&(h[19]=x,m.length++),m};Math.imul||(P=O);function z(p,a,d){d.negative=a.negative^p.negative,d.length=p.length+a.length;for(var m=0,_=0,y=0;y>>26)|0,_+=h>>>26,h&=67108863}d.words[y]=x,m=h,h=_}return m!==0?d.words[y]=m:d.length--,d._strip()}function B(p,a,d){return z(p,a,d)}n.prototype.mulTo=function(a,d){var m,_=this.length+a.length;return this.length===10&&a.length===10?m=P(this,a,d):_<63?m=O(this,a,d):_<1024?m=z(this,a,d):m=B(this,a,d),m};function U(p,a){this.x=p,this.y=a}U.prototype.makeRBT=function(a){for(var d=new Array(a),m=n.prototype._countBits(a)-1,_=0;_>=1;return _},U.prototype.permute=function(a,d,m,_,y,h){for(var x=0;x>>1)y++;return 1<>>13,m[2*h+1]=y&8191,y=y>>>13;for(h=2*d;h<_;++h)m[h]=0;t(y===0),t((y&-8192)===0)},U.prototype.stub=function(a){for(var d=new Array(a),m=0;m>=26,m+=y/67108864|0,m+=h>>>26,this.words[_]=h&67108863}return m!==0&&(this.words[_]=m,this.length++),d?this.ineg():this},n.prototype.muln=function(a){return this.clone().imuln(a)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(a){var d=T(a);if(d.length===0)return new n(1);for(var m=this,_=0;_=0);var d=a%26,m=(a-d)/26,_=67108863>>>26-d<<26-d,y;if(d!==0){var h=0;for(y=0;y>>26-d}h&&(this.words[y]=h,this.length++)}if(m!==0){for(y=this.length-1;y>=0;y--)this.words[y+m]=this.words[y];for(y=0;y=0);var _;d?_=(d-d%26)/26:_=0;var y=a%26,h=Math.min((a-y)/26,this.length),x=67108863^67108863>>>y<h)for(this.length-=h,g=0;g=0&&(R!==0||g>=_);g--){var k=this.words[g]|0;this.words[g]=R<<26-y|k>>>y,R=k&x}return A&&R!==0&&(A.words[A.length++]=R),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(a,d,m){return t(this.negative===0),this.iushrn(a,d,m)},n.prototype.shln=function(a){return this.clone().ishln(a)},n.prototype.ushln=function(a){return this.clone().iushln(a)},n.prototype.shrn=function(a){return this.clone().ishrn(a)},n.prototype.ushrn=function(a){return this.clone().iushrn(a)},n.prototype.testn=function(a){t(typeof a=="number"&&a>=0);var d=a%26,m=(a-d)/26,_=1<=0);var d=a%26,m=(a-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=m)return this;if(d!==0&&m++,this.length=Math.min(m,this.length),d!==0){var _=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(a){if(t(typeof a=="number"),t(a<67108864),a<0)return this.iaddn(-a);if(this.negative!==0)return this.negative=0,this.iaddn(a),this.negative=1,this;if(this.words[0]-=a,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(A/67108864|0),this.words[y+m]=h&67108863}for(;y>26,this.words[y+m]=h&67108863;if(x===0)return this._strip();for(t(x===-1),x=0,y=0;y>26,this.words[y]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(a,d){var m=this.length-a.length,_=this.clone(),y=a,h=y.words[y.length-1]|0,x=this._countBits(h);m=26-x,m!==0&&(y=y.ushln(m),_.iushln(m),h=y.words[y.length-1]|0);var A=_.length-y.length,g;if(d!=="mod"){g=new n(null),g.length=A+1,g.words=new Array(g.length);for(var R=0;R=0;E--){var N=(_.words[y.length+E]|0)*67108864+(_.words[y.length+E-1]|0);for(N=Math.min(N/h|0,67108863),_._ishlnsubmul(y,N,E);_.negative!==0;)N--,_.negative=0,_._ishlnsubmul(y,1,E),_.isZero()||(_.negative^=1);g&&(g.words[E]=N)}return g&&g._strip(),_._strip(),d!=="div"&&m!==0&&_.iushrn(m),{div:g||null,mod:_}},n.prototype.divmod=function(a,d,m){if(t(!a.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var _,y,h;return this.negative!==0&&a.negative===0?(h=this.neg().divmod(a,d),d!=="mod"&&(_=h.div.neg()),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.iadd(a)),{div:_,mod:y}):this.negative===0&&a.negative!==0?(h=this.divmod(a.neg(),d),d!=="mod"&&(_=h.div.neg()),{div:_,mod:h.mod}):this.negative&a.negative?(h=this.neg().divmod(a.neg(),d),d!=="div"&&(y=h.mod.neg(),m&&y.negative!==0&&y.isub(a)),{div:h.div,mod:y}):a.length>this.length||this.cmp(a)<0?{div:new n(0),mod:this}:a.length===1?d==="div"?{div:this.divn(a.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(a.words[0]))}:{div:this.divn(a.words[0]),mod:new n(this.modrn(a.words[0]))}:this._wordDiv(a,d)},n.prototype.div=function(a){return this.divmod(a,"div",!1).div},n.prototype.mod=function(a){return this.divmod(a,"mod",!1).mod},n.prototype.umod=function(a){return this.divmod(a,"mod",!0).mod},n.prototype.divRound=function(a){var d=this.divmod(a);if(d.mod.isZero())return d.div;var m=d.div.negative!==0?d.mod.isub(a):d.mod,_=a.ushrn(1),y=a.andln(1),h=m.cmp(_);return h<0||y===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=(1<<26)%a,_=0,y=this.length-1;y>=0;y--)_=(m*_+(this.words[y]|0))%a;return d?-_:_},n.prototype.modn=function(a){return this.modrn(a)},n.prototype.idivn=function(a){var d=a<0;d&&(a=-a),t(a<=67108863);for(var m=0,_=this.length-1;_>=0;_--){var y=(this.words[_]|0)+m*67108864;this.words[_]=y/a|0,m=y%a}return this._strip(),d?this.ineg():this},n.prototype.divn=function(a){return this.clone().idivn(a)},n.prototype.egcd=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=new n(0),x=new n(1),A=0;d.isEven()&&m.isEven();)d.iushrn(1),m.iushrn(1),++A;for(var g=m.clone(),R=d.clone();!d.isZero();){for(var k=0,E=1;!(d.words[0]&E)&&k<26;++k,E<<=1);if(k>0)for(d.iushrn(k);k-- >0;)(_.isOdd()||y.isOdd())&&(_.iadd(g),y.isub(R)),_.iushrn(1),y.iushrn(1);for(var N=0,F=1;!(m.words[0]&F)&&N<26;++N,F<<=1);if(N>0)for(m.iushrn(N);N-- >0;)(h.isOdd()||x.isOdd())&&(h.iadd(g),x.isub(R)),h.iushrn(1),x.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(h),y.isub(x)):(m.isub(d),h.isub(_),x.isub(y))}return{a:h,b:x,gcd:m.iushln(A)}},n.prototype._invmp=function(a){t(a.negative===0),t(!a.isZero());var d=this,m=a.clone();d.negative!==0?d=d.umod(a):d=d.clone();for(var _=new n(1),y=new n(0),h=m.clone();d.cmpn(1)>0&&m.cmpn(1)>0;){for(var x=0,A=1;!(d.words[0]&A)&&x<26;++x,A<<=1);if(x>0)for(d.iushrn(x);x-- >0;)_.isOdd()&&_.iadd(h),_.iushrn(1);for(var g=0,R=1;!(m.words[0]&R)&&g<26;++g,R<<=1);if(g>0)for(m.iushrn(g);g-- >0;)y.isOdd()&&y.iadd(h),y.iushrn(1);d.cmp(m)>=0?(d.isub(m),_.isub(y)):(m.isub(d),y.isub(_))}var k;return d.cmpn(1)===0?k=_:k=y,k.cmpn(0)<0&&k.iadd(a),k},n.prototype.gcd=function(a){if(this.isZero())return a.abs();if(a.isZero())return this.abs();var d=this.clone(),m=a.clone();d.negative=0,m.negative=0;for(var _=0;d.isEven()&&m.isEven();_++)d.iushrn(1),m.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;m.isEven();)m.iushrn(1);var y=d.cmp(m);if(y<0){var h=d;d=m,m=h}else if(y===0||m.cmpn(1)===0)break;d.isub(m)}while(!0);return m.iushln(_)},n.prototype.invm=function(a){return this.egcd(a).a.umod(a)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(a){return this.words[0]&a},n.prototype.bincn=function(a){t(typeof a=="number");var d=a%26,m=(a-d)/26,_=1<>>26,x&=67108863,this.words[h]=x}return y!==0&&(this.words[h]=y,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(a){var d=a<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var m;if(this.length>1)m=1;else{d&&(a=-a),t(a<=67108863,"Number is too big");var _=this.words[0]|0;m=_===a?0:_a.length)return 1;if(this.length=0;m--){var _=this.words[m]|0,y=a.words[m]|0;if(_!==y){_y&&(d=1);break}}return d},n.prototype.gtn=function(a){return this.cmpn(a)===1},n.prototype.gt=function(a){return this.cmp(a)===1},n.prototype.gten=function(a){return this.cmpn(a)>=0},n.prototype.gte=function(a){return this.cmp(a)>=0},n.prototype.ltn=function(a){return this.cmpn(a)===-1},n.prototype.lt=function(a){return this.cmp(a)===-1},n.prototype.lten=function(a){return this.cmpn(a)<=0},n.prototype.lte=function(a){return this.cmp(a)<=0},n.prototype.eqn=function(a){return this.cmpn(a)===0},n.prototype.eq=function(a){return this.cmp(a)===0},n.red=function(a){return new l(a)},n.prototype.toRed=function(a){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),a.convertTo(this)._forceRed(a)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(a){return this.red=a,this},n.prototype.forceRed=function(a){return t(!this.red,"Already a number in reduction context"),this._forceRed(a)},n.prototype.redAdd=function(a){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,a)},n.prototype.redIAdd=function(a){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,a)},n.prototype.redSub=function(a){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,a)},n.prototype.redISub=function(a){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,a)},n.prototype.redShl=function(a){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,a)},n.prototype.redMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.mul(this,a)},n.prototype.redIMul=function(a){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,a),this.red.imul(this,a)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(a){return t(this.red&&!a.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,a)};var j={k256:null,p224:null,p192:null,p25519:null};function H(p,a){this.name=p,this.p=new n(a,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}H.prototype._tmp=function(){var a=new n(null);return a.words=new Array(Math.ceil(this.n/13)),a},H.prototype.ireduce=function(a){var d=a,m;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),m=d.bitLength();while(m>this.n);var _=m0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},H.prototype.split=function(a,d){a.iushrn(this.n,0,d)},H.prototype.imulK=function(a){return a.imul(this.k)};function L(){H.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,H),L.prototype.split=function(a,d){for(var m=4194303,_=Math.min(a.length,9),y=0;y<_;y++)d.words[y]=a.words[y];if(d.length=_,a.length<=9){a.words[0]=0,a.length=1;return}var h=a.words[9];for(d.words[d.length++]=h&m,y=10;y>>22,h=x}h>>>=22,a.words[y-10]=h,h===0&&a.length>10?a.length-=10:a.length-=9},L.prototype.imulK=function(a){a.words[a.length]=0,a.words[a.length+1]=0,a.length+=2;for(var d=0,m=0;m>>=26,a.words[m]=y,d=_}return d!==0&&(a.words[a.length++]=d),a},n._prime=function(a){if(j[a])return j[a];var d;if(a==="k256")d=new L;else if(a==="p224")d=new C;else if(a==="p192")d=new W;else if(a==="p25519")d=new D;else throw new Error("Unknown prime "+a);return j[a]=d,d};function l(p){if(typeof p=="string"){var a=n._prime(p);this.m=a.p,this.prime=a}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(a){t(a.negative===0,"red works only with positives"),t(a.red,"red works only with red numbers")},l.prototype._verify2=function(a,d){t((a.negative|d.negative)===0,"red works only with positives"),t(a.red&&a.red===d.red,"red works only with red numbers")},l.prototype.imod=function(a){return this.prime?this.prime.ireduce(a)._forceRed(this):(c(a,a.umod(this.m)._forceRed(this)),a)},l.prototype.neg=function(a){return a.isZero()?a.clone():this.m.sub(a)._forceRed(this)},l.prototype.add=function(a,d){this._verify2(a,d);var m=a.add(d);return m.cmp(this.m)>=0&&m.isub(this.m),m._forceRed(this)},l.prototype.iadd=function(a,d){this._verify2(a,d);var m=a.iadd(d);return m.cmp(this.m)>=0&&m.isub(this.m),m},l.prototype.sub=function(a,d){this._verify2(a,d);var m=a.sub(d);return m.cmpn(0)<0&&m.iadd(this.m),m._forceRed(this)},l.prototype.isub=function(a,d){this._verify2(a,d);var m=a.isub(d);return m.cmpn(0)<0&&m.iadd(this.m),m},l.prototype.shl=function(a,d){return this._verify1(a),this.imod(a.ushln(d))},l.prototype.imul=function(a,d){return this._verify2(a,d),this.imod(a.imul(d))},l.prototype.mul=function(a,d){return this._verify2(a,d),this.imod(a.mul(d))},l.prototype.isqr=function(a){return this.imul(a,a.clone())},l.prototype.sqr=function(a){return this.mul(a,a)},l.prototype.sqrt=function(a){if(a.isZero())return a.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var m=this.m.add(new n(1)).iushrn(2);return this.pow(a,m)}for(var _=this.m.subn(1),y=0;!_.isZero()&&_.andln(1)===0;)y++,_.iushrn(1);t(!_.isZero());var h=new n(1).toRed(this),x=h.redNeg(),A=this.m.subn(1).iushrn(1),g=this.m.bitLength();for(g=new n(2*g*g).toRed(this);this.pow(g,A).cmp(x)!==0;)g.redIAdd(x);for(var R=this.pow(g,_),k=this.pow(a,_.addn(1).iushrn(1)),E=this.pow(a,_),N=y;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;y--){for(var R=d.words[y],k=g-1;k>=0;k--){var E=R>>k&1;if(h!==_[0]&&(h=this.sqr(h)),E===0&&x===0){A=0;continue}x<<=1,x|=E,A++,!(A!==m&&(y!==0||k!==0))&&(h=this.mul(h,_[x]),A=0,x=0)}g=26}return h},l.prototype.convertTo=function(a){var d=a.umod(this.m);return d===a?d.clone():d},l.prototype.convertFrom=function(a){var d=a.clone();return d.red=null,d},n.mont=function(a){return new w(a)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(a){return this.imod(a.ushln(this.shift))},w.prototype.convertFrom=function(a){var d=this.imod(a.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(a,d){if(a.isZero()||d.isZero())return a.words[0]=0,a.length=1,a;var m=a.imul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(a,d){if(a.isZero()||d.isZero())return new n(0)._forceRed(this);var m=a.mul(d),_=m.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),y=m.isub(_).iushrn(this.shift),h=y;return y.cmp(this.m)>=0?h=y.isub(this.m):y.cmpn(0)<0&&(h=y.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(a){var d=this.imod(a._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof Dh>"u"||Dh,Gp)});var Pi=Z((UA,o1)=>{o1.exports=s1;function s1(r,e){if(!r)throw new Error(e||"Assertion failed")}s1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var co=Z((zA,Oh)=>{typeof Object.create=="function"?Oh.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:Oh.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var fr=Z(Ve=>{"use strict";var jw=Pi(),Vw=co();Ve.inherits=Vw;function $w(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function Hw(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):$w(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ve.htonl=a1;function Ww(r,e){for(var t="",i=0;i>>0}return s}Ve.join32=Jw;function Yw(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ve.split32=Yw;function Xw(r,e){return r>>>e|r<<32-e}Ve.rotr32=Xw;function Zw(r,e){return r<>>32-e}Ve.rotl32=Zw;function Qw(r,e){return r+e>>>0}Ve.sum32=Qw;function e5(r,e,t){return r+e+t>>>0}Ve.sum32_3=e5;function t5(r,e,t,i){return r+e+t+i>>>0}Ve.sum32_4=t5;function r5(r,e,t,i,n){return r+e+t+i+n>>>0}Ve.sum32_5=r5;function i5(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,f=(o>>0,r[e+1]=o}Ve.sum64=i5;function n5(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ve.sum64_hi=n5;function s5(r,e,t,i){var n=e+i;return n>>>0}Ve.sum64_lo=s5;function o5(r,e,t,i,n,s,o,f){var u=0,c=e;c=c+i>>>0,u+=c>>0,u+=c>>0,u+=c>>0}Ve.sum64_4_hi=o5;function a5(r,e,t,i,n,s,o,f){var u=e+i+s+f;return u>>>0}Ve.sum64_4_lo=a5;function f5(r,e,t,i,n,s,o,f,u,c){var b=0,v=e;v=v+i>>>0,b+=v>>0,b+=v>>0,b+=v>>0,b+=v>>0}Ve.sum64_5_hi=f5;function c5(r,e,t,i,n,s,o,f,u,c){var b=e+i+s+f+c;return b>>>0}Ve.sum64_5_lo=c5;function h5(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ve.rotr64_hi=h5;function u5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.rotr64_lo=u5;function d5(r,e,t){return r>>>t}Ve.shr64_hi=d5;function l5(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ve.shr64_lo=l5});var os=Z(u1=>{"use strict";var h1=fr(),p5=Pi();function Ga(){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}u1.BlockHash=Ga;Ga.prototype.update=function(e,t){if(e=h1.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=h1.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var g5=fr(),zr=g5.rotr32;function b5(r,e,t,i){if(r===0)return d1(e,t,i);if(r===1||r===3)return p1(e,t,i);if(r===2)return l1(e,t,i)}ui.ft_1=b5;function d1(r,e,t){return r&e^~r&t}ui.ch32=d1;function l1(r,e,t){return r&e^r&t^e&t}ui.maj32=l1;function p1(r,e,t){return r^e^t}ui.p32=p1;function v5(r){return zr(r,2)^zr(r,13)^zr(r,22)}ui.s0_256=v5;function m5(r){return zr(r,6)^zr(r,11)^zr(r,25)}ui.s1_256=m5;function y5(r){return zr(r,7)^zr(r,18)^r>>>3}ui.g0_256=y5;function w5(r){return zr(r,17)^zr(r,19)^r>>>10}ui.g1_256=w5});var v1=Z((jA,b1)=>{"use strict";var as=fr(),_5=os(),x5=Lh(),Fh=as.rotl32,ho=as.sum32,E5=as.sum32_5,S5=x5.ft_1,g1=_5.BlockHash,I5=[1518500249,1859775393,2400959708,3395469782];function Br(){if(!(this instanceof Br))return new Br;g1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}as.inherits(Br,g1);b1.exports=Br;Br.blockSize=512;Br.outSize=160;Br.hmacStrength=80;Br.padLength=64;Br.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var fs=fr(),M5=os(),cs=Lh(),A5=Pi(),cr=fs.sum32,R5=fs.sum32_4,T5=fs.sum32_5,D5=cs.ch32,P5=cs.maj32,N5=cs.s0_256,C5=cs.s1_256,O5=cs.g0_256,L5=cs.g1_256,m1=M5.BlockHash,F5=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function kr(){if(!(this instanceof kr))return new kr;m1.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=F5,this.W=new Array(64)}fs.inherits(kr,m1);y1.exports=kr;kr.blockSize=512;kr.outSize=256;kr.hmacStrength=192;kr.padLength=64;kr.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var Uh=fr(),w1=qh();function di(){if(!(this instanceof di))return new di;w1.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}Uh.inherits(di,w1);_1.exports=di;di.blockSize=512;di.outSize=224;di.hmacStrength=192;di.padLength=64;di.prototype._digest=function(e){return e==="hex"?Uh.toHex32(this.h.slice(0,7),"big"):Uh.split32(this.h.slice(0,7),"big")}});var kh=Z((HA,M1)=>{"use strict";var Ot=fr(),q5=os(),U5=Pi(),Kr=Ot.rotr64_hi,jr=Ot.rotr64_lo,E1=Ot.shr64_hi,S1=Ot.shr64_lo,Ni=Ot.sum64,zh=Ot.sum64_hi,Bh=Ot.sum64_lo,z5=Ot.sum64_4_hi,B5=Ot.sum64_4_lo,k5=Ot.sum64_5_hi,K5=Ot.sum64_5_lo,I1=q5.BlockHash,j5=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function hr(){if(!(this instanceof hr))return new hr;I1.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=j5,this.W=new Array(160)}Ot.inherits(hr,I1);M1.exports=hr;hr.blockSize=1024;hr.outSize=512;hr.hmacStrength=192;hr.padLength=128;hr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Kh=fr(),A1=kh();function li(){if(!(this instanceof li))return new li;A1.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Kh.inherits(li,A1);R1.exports=li;li.blockSize=1024;li.outSize=384;li.hmacStrength=192;li.padLength=128;li.prototype._digest=function(e){return e==="hex"?Kh.toHex32(this.h.slice(0,12),"big"):Kh.split32(this.h.slice(0,12),"big")}});var D1=Z(hs=>{"use strict";hs.sha1=v1();hs.sha224=x1();hs.sha256=qh();hs.sha384=T1();hs.sha512=kh()});var F1=Z(L1=>{"use strict";var _n=fr(),r8=os(),Wa=_n.rotl32,P1=_n.sum32,uo=_n.sum32_3,N1=_n.sum32_4,O1=r8.BlockHash;function Vr(){if(!(this instanceof Vr))return new Vr;O1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}_n.inherits(Vr,O1);L1.ripemd160=Vr;Vr.blockSize=512;Vr.outSize=160;Vr.hmacStrength=192;Vr.padLength=64;Vr.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],f=this.h[4],u=i,c=n,b=s,v=o,S=f,I=0;I<80;I++){var M=P1(Wa(N1(i,C1(I,n,s,o),e[s8[I]+t],i8(I)),a8[I]),f);i=f,f=o,o=Wa(s,10),s=n,n=M,M=P1(Wa(N1(u,C1(79-I,c,b,v),e[o8[I]+t],n8(I)),f8[I]),S),u=S,S=v,v=Wa(b,10),b=c,c=M}M=uo(this.h[1],s,v),this.h[1]=uo(this.h[2],o,S),this.h[2]=uo(this.h[3],f,u),this.h[3]=uo(this.h[4],i,c),this.h[4]=uo(this.h[0],n,b),this.h[0]=M};Vr.prototype._digest=function(e){return e==="hex"?_n.toHex32(this.h,"little"):_n.split32(this.h,"little")};function C1(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function i8(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function n8(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var s8=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],o8=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],a8=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],f8=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var U1=Z((YA,q1)=>{"use strict";var c8=fr(),h8=Pi();function us(r,e,t){if(!(this instanceof us))return new us(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(c8.toArray(e,t))}q1.exports=us;us.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),h8(e.length<=this.blockSize);for(var t=e.length;t{var pt=z1;pt.utils=fr();pt.common=os();pt.sha=D1();pt.ripemd=F1();pt.hmac=U1();pt.sha1=pt.sha.sha1;pt.sha256=pt.sha.sha256;pt.sha224=pt.sha.sha224;pt.sha384=pt.sha.sha384;pt.sha512=pt.sha.sha512;pt.ripemd160=pt.ripemd.ripemd160});var X1=Z(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});var Et=Hn(),Qh=Jt(),_8=20;function x8(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,f=t[3]<<24|t[2]<<16|t[1]<<8|t[0],u=t[7]<<24|t[6]<<16|t[5]<<8|t[4],c=t[11]<<24|t[10]<<16|t[9]<<8|t[8],b=t[15]<<24|t[14]<<16|t[13]<<8|t[12],v=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],M=t[31]<<24|t[30]<<16|t[29]<<8|t[28],T=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],P=e[11]<<24|e[10]<<16|e[9]<<8|e[8],z=e[15]<<24|e[14]<<16|e[13]<<8|e[12],B=i,U=n,j=s,H=o,L=f,C=u,W=c,D=b,l=v,w=S,p=I,a=M,d=T,m=O,_=P,y=z,h=0;h<_8;h+=2)B=B+L|0,d^=B,d=d>>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,U=U+C|0,m^=U,m=m>>>16|m<<16,w=w+m|0,C^=w,C=C>>>20|C<<12,j=j+W|0,_^=j,_=_>>>16|_<<16,p=p+_|0,W^=p,W=W>>>20|W<<12,H=H+D|0,y^=H,y=y>>>16|y<<16,a=a+y|0,D^=a,D=D>>>20|D<<12,j=j+W|0,_^=j,_=_>>>24|_<<8,p=p+_|0,W^=p,W=W>>>25|W<<7,H=H+D|0,y^=H,y=y>>>24|y<<8,a=a+y|0,D^=a,D=D>>>25|D<<7,U=U+C|0,m^=U,m=m>>>24|m<<8,w=w+m|0,C^=w,C=C>>>25|C<<7,B=B+L|0,d^=B,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,B=B+C|0,y^=B,y=y>>>16|y<<16,p=p+y|0,C^=p,C=C>>>20|C<<12,U=U+W|0,d^=U,d=d>>>16|d<<16,a=a+d|0,W^=a,W=W>>>20|W<<12,j=j+D|0,m^=j,m=m>>>16|m<<16,l=l+m|0,D^=l,D=D>>>20|D<<12,H=H+L|0,_^=H,_=_>>>16|_<<16,w=w+_|0,L^=w,L=L>>>20|L<<12,j=j+D|0,m^=j,m=m>>>24|m<<8,l=l+m|0,D^=l,D=D>>>25|D<<7,H=H+L|0,_^=H,_=_>>>24|_<<8,w=w+_|0,L^=w,L=L>>>25|L<<7,U=U+W|0,d^=U,d=d>>>24|d<<8,a=a+d|0,W^=a,W=W>>>25|W<<7,B=B+C|0,y^=B,y=y>>>24|y<<8,p=p+y|0,C^=p,C=C>>>25|C<<7;Et.writeUint32LE(B+i|0,r,0),Et.writeUint32LE(U+n|0,r,4),Et.writeUint32LE(j+s|0,r,8),Et.writeUint32LE(H+o|0,r,12),Et.writeUint32LE(L+f|0,r,16),Et.writeUint32LE(C+u|0,r,20),Et.writeUint32LE(W+c|0,r,24),Et.writeUint32LE(D+b|0,r,28),Et.writeUint32LE(l+v|0,r,32),Et.writeUint32LE(w+S|0,r,36),Et.writeUint32LE(p+I|0,r,40),Et.writeUint32LE(a+M|0,r,44),Et.writeUint32LE(d+T|0,r,48),Et.writeUint32LE(m+O|0,r,52),Et.writeUint32LE(_+P|0,r,56),Et.writeUint32LE(y+z|0,r,60)}function Y1(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var rf=Z(ls=>{"use strict";Object.defineProperty(ls,"__esModule",{value:!0});function I8(r,e,t){return~(r-1)&e|r-1&t}ls.select=I8;function M8(r,e){return(r|0)-(e|0)-1>>>31&1}ls.lessOrEqual=M8;function Z1(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}ls.compare=Z1;function A8(r,e){return r.length===0||e.length===0?!1:Z1(r,e)!==0}ls.equal=A8});var eg=Z(pi=>{"use strict";Object.defineProperty(pi,"__esModule",{value:!0});var R8=rf(),nf=Jt();pi.DIGEST_LENGTH=16;var Q1=function(){function r(e){this.digestLength=pi.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var f=e[10]|e[11]<<8;this._r[6]=(o>>>14|f<<2)&8191;var u=e[12]|e[13]<<8;this._r[7]=(f>>>11|u<<5)&8065;var c=e[14]|e[15]<<8;this._r[8]=(u>>>8|c<<8)&8191,this._r[9]=c>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],f=this._h[2],u=this._h[3],c=this._h[4],b=this._h[5],v=this._h[6],S=this._h[7],I=this._h[8],M=this._h[9],T=this._r[0],O=this._r[1],P=this._r[2],z=this._r[3],B=this._r[4],U=this._r[5],j=this._r[6],H=this._r[7],L=this._r[8],C=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var D=e[t+2]|e[t+3]<<8;o+=(W>>>13|D<<3)&8191;var l=e[t+4]|e[t+5]<<8;f+=(D>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;u+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;c+=(w>>>4|p<<12)&8191,b+=p>>>1&8191;var a=e[t+10]|e[t+11]<<8;v+=(p>>>14|a<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(a>>>11|d<<5)&8191;var m=e[t+14]|e[t+15]<<8;I+=(d>>>8|m<<8)&8191,M+=m>>>5|n;var _=0,y=_;y+=s*T,y+=o*(5*C),y+=f*(5*L),y+=u*(5*H),y+=c*(5*j),_=y>>>13,y&=8191,y+=b*(5*U),y+=v*(5*B),y+=S*(5*z),y+=I*(5*P),y+=M*(5*O),_+=y>>>13,y&=8191;var h=_;h+=s*O,h+=o*T,h+=f*(5*C),h+=u*(5*L),h+=c*(5*H),_=h>>>13,h&=8191,h+=b*(5*j),h+=v*(5*U),h+=S*(5*B),h+=I*(5*z),h+=M*(5*P),_+=h>>>13,h&=8191;var x=_;x+=s*P,x+=o*O,x+=f*T,x+=u*(5*C),x+=c*(5*L),_=x>>>13,x&=8191,x+=b*(5*H),x+=v*(5*j),x+=S*(5*U),x+=I*(5*B),x+=M*(5*z),_+=x>>>13,x&=8191;var A=_;A+=s*z,A+=o*P,A+=f*O,A+=u*T,A+=c*(5*C),_=A>>>13,A&=8191,A+=b*(5*L),A+=v*(5*H),A+=S*(5*j),A+=I*(5*U),A+=M*(5*B),_+=A>>>13,A&=8191;var g=_;g+=s*B,g+=o*z,g+=f*P,g+=u*O,g+=c*T,_=g>>>13,g&=8191,g+=b*(5*C),g+=v*(5*L),g+=S*(5*H),g+=I*(5*j),g+=M*(5*U),_+=g>>>13,g&=8191;var R=_;R+=s*U,R+=o*B,R+=f*z,R+=u*P,R+=c*O,_=R>>>13,R&=8191,R+=b*T,R+=v*(5*C),R+=S*(5*L),R+=I*(5*H),R+=M*(5*j),_+=R>>>13,R&=8191;var k=_;k+=s*j,k+=o*U,k+=f*B,k+=u*z,k+=c*P,_=k>>>13,k&=8191,k+=b*O,k+=v*T,k+=S*(5*C),k+=I*(5*L),k+=M*(5*H),_+=k>>>13,k&=8191;var E=_;E+=s*H,E+=o*j,E+=f*U,E+=u*B,E+=c*z,_=E>>>13,E&=8191,E+=b*P,E+=v*O,E+=S*T,E+=I*(5*C),E+=M*(5*L),_+=E>>>13,E&=8191;var N=_;N+=s*L,N+=o*H,N+=f*j,N+=u*U,N+=c*B,_=N>>>13,N&=8191,N+=b*z,N+=v*P,N+=S*O,N+=I*T,N+=M*(5*C),_+=N>>>13,N&=8191;var F=_;F+=s*C,F+=o*L,F+=f*H,F+=u*j,F+=c*U,_=F>>>13,F&=8191,F+=b*B,F+=v*z,F+=S*P,F+=I*O,F+=M*T,_+=F>>>13,F&=8191,_=(_<<2)+_|0,_=_+y|0,y=_&8191,_=_>>>13,h+=_,s=y,o=h,f=x,u=A,c=g,b=R,v=k,S=E,I=N,M=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=f,this._h[3]=u,this._h[4]=c,this._h[5]=b,this._h[6]=v,this._h[7]=S,this._h[8]=I,this._h[9]=M},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,f;if(this._leftover){for(f=this._leftover,this._buffer[f++]=1;f<16;f++)this._buffer[f]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,f=2;f<10;f++)this._h[f]+=n,n=this._h[f]>>>13,this._h[f]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,f=1;f<10;f++)i[f]=this._h[f]+n,n=i[f]>>>13,i[f]&=8191;for(i[9]-=8192,s=(n^1)-1,f=0;f<10;f++)i[f]&=s;for(s=~s,f=0;f<10;f++)this._h[f]=this._h[f]&s|i[f];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,f=1;f<8;f++)o=(this._h[f]+this._pad[f]|0)+(o>>>16)|0,this._h[f]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(gi,"__esModule",{value:!0});var sf=X1(),P8=eg(),po=Jt(),tg=Hn(),N8=rf();gi.KEY_LENGTH=32;gi.NONCE_LENGTH=12;gi.TAG_LENGTH=16;var rg=new Uint8Array(16),C8=function(){function r(e){if(this.nonceLength=gi.NONCE_LENGTH,this.tagLength=gi.TAG_LENGTH,e.length!==gi.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);sf.stream(this._key,s,o,4);var f=t.length+this.tagLength,u;if(n){if(n.length!==f)throw new Error("ChaCha20Poly1305: incorrect destination length");u=n}else u=new Uint8Array(f);return sf.streamXOR(this._key,s,t,u,4),this._authenticate(u.subarray(u.length-this.tagLength,u.length),o,u.subarray(0,u.length-this.tagLength),i),po.wipe(s),u},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(rg.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(rg.subarray(i.length%16));var o=new Uint8Array(8);n&&tg.writeUint64LE(n.length,o),s.update(o),tg.writeUint64LE(i.length,o),s.update(o);for(var f=s.digest(),u=0;u{"use strict";Object.defineProperty(eu,"__esModule",{value:!0});function O8(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}eu.isSerializableHash=O8});var og=Z(go=>{"use strict";Object.defineProperty(go,"__esModule",{value:!0});var Gr=ng(),L8=rf(),F8=Jt(),sg=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(tu,"__esModule",{value:!0});var ag=og(),fg=Jt(),U8=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=ag.hmac(this._hash,i,t);this._hmac=new ag.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Li,"__esModule",{value:!0});var af=Hn(),of=Jt();Li.DIGEST_LENGTH=32;Li.BLOCK_SIZE=64;var hg=function(){function r(){this.digestLength=Li.DIGEST_LENGTH,this.blockSize=Li.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){of.wipe(this._buffer),of.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(ru(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=ru(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var f=i+1;f0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){of.wipe(e.state),e.buffer&&of.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Li.SHA256=hg;var z8=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function ru(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],f=e[2],u=e[3],c=e[4],b=e[5],v=e[6],S=e[7],I=0;I<16;I++){var M=i+I*4;r[I]=af.readUint32BE(t,M)}for(var I=16;I<64;I++){var T=r[I-2],O=(T>>>17|T<<15)^(T>>>19|T<<13)^T>>>10;T=r[I-15];var P=(T>>>7|T<<25)^(T>>>18|T<<14)^T>>>3;r[I]=(O+r[I-7]|0)+(P+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((c>>>6|c<<26)^(c>>>11|c<<21)^(c>>>25|c<<7))+(c&b^~c&v)|0)+(S+(z8[I]+r[I]|0)|0)|0,P=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&f^o&f)|0;S=v,v=b,b=c,c=u+O|0,u=f,f=o,o=s,s=O+P|0}e[0]+=s,e[1]+=o,e[2]+=f,e[3]+=u,e[4]+=c,e[5]+=b,e[6]+=v,e[7]+=S,i+=64,n-=64}return i}function B8(r){var e=new hg;e.update(r);var t=e.digest();return e.clean(),t}Li.hash=B8});var gg=Z(Qe=>{"use strict";Object.defineProperty(Qe,"__esModule",{value:!0});Qe.sharedKey=Qe.generateKeyPair=Qe.generateKeyPairFromSeed=Qe.scalarMultBase=Qe.scalarMult=Qe.SHARED_KEY_LENGTH=Qe.SECRET_KEY_LENGTH=Qe.PUBLIC_KEY_LENGTH=void 0;var k8=Js(),K8=Jt();Qe.PUBLIC_KEY_LENGTH=32;Qe.SECRET_KEY_LENGTH=32;Qe.SHARED_KEY_LENGTH=32;function Wr(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,bo(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function $8(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function ff(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function cf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function bi(r,e,t){let i,n,s=0,o=0,f=0,u=0,c=0,b=0,v=0,S=0,I=0,M=0,T=0,O=0,P=0,z=0,B=0,U=0,j=0,H=0,L=0,C=0,W=0,D=0,l=0,w=0,p=0,a=0,d=0,m=0,_=0,y=0,h=0,x=t[0],A=t[1],g=t[2],R=t[3],k=t[4],E=t[5],N=t[6],F=t[7],q=t[8],K=t[9],J=t[10],$=t[11],V=t[12],ee=t[13],G=t[14],Y=t[15];i=e[0],s+=i*x,o+=i*A,f+=i*g,u+=i*R,c+=i*k,b+=i*E,v+=i*N,S+=i*F,I+=i*q,M+=i*K,T+=i*J,O+=i*$,P+=i*V,z+=i*ee,B+=i*G,U+=i*Y,i=e[1],o+=i*x,f+=i*A,u+=i*g,c+=i*R,b+=i*k,v+=i*E,S+=i*N,I+=i*F,M+=i*q,T+=i*K,O+=i*J,P+=i*$,z+=i*V,B+=i*ee,U+=i*G,j+=i*Y,i=e[2],f+=i*x,u+=i*A,c+=i*g,b+=i*R,v+=i*k,S+=i*E,I+=i*N,M+=i*F,T+=i*q,O+=i*K,P+=i*J,z+=i*$,B+=i*V,U+=i*ee,j+=i*G,H+=i*Y,i=e[3],u+=i*x,c+=i*A,b+=i*g,v+=i*R,S+=i*k,I+=i*E,M+=i*N,T+=i*F,O+=i*q,P+=i*K,z+=i*J,B+=i*$,U+=i*V,j+=i*ee,H+=i*G,L+=i*Y,i=e[4],c+=i*x,b+=i*A,v+=i*g,S+=i*R,I+=i*k,M+=i*E,T+=i*N,O+=i*F,P+=i*q,z+=i*K,B+=i*J,U+=i*$,j+=i*V,H+=i*ee,L+=i*G,C+=i*Y,i=e[5],b+=i*x,v+=i*A,S+=i*g,I+=i*R,M+=i*k,T+=i*E,O+=i*N,P+=i*F,z+=i*q,B+=i*K,U+=i*J,j+=i*$,H+=i*V,L+=i*ee,C+=i*G,W+=i*Y,i=e[6],v+=i*x,S+=i*A,I+=i*g,M+=i*R,T+=i*k,O+=i*E,P+=i*N,z+=i*F,B+=i*q,U+=i*K,j+=i*J,H+=i*$,L+=i*V,C+=i*ee,W+=i*G,D+=i*Y,i=e[7],S+=i*x,I+=i*A,M+=i*g,T+=i*R,O+=i*k,P+=i*E,z+=i*N,B+=i*F,U+=i*q,j+=i*K,H+=i*J,L+=i*$,C+=i*V,W+=i*ee,D+=i*G,l+=i*Y,i=e[8],I+=i*x,M+=i*A,T+=i*g,O+=i*R,P+=i*k,z+=i*E,B+=i*N,U+=i*F,j+=i*q,H+=i*K,L+=i*J,C+=i*$,W+=i*V,D+=i*ee,l+=i*G,w+=i*Y,i=e[9],M+=i*x,T+=i*A,O+=i*g,P+=i*R,z+=i*k,B+=i*E,U+=i*N,j+=i*F,H+=i*q,L+=i*K,C+=i*J,W+=i*$,D+=i*V,l+=i*ee,w+=i*G,p+=i*Y,i=e[10],T+=i*x,O+=i*A,P+=i*g,z+=i*R,B+=i*k,U+=i*E,j+=i*N,H+=i*F,L+=i*q,C+=i*K,W+=i*J,D+=i*$,l+=i*V,w+=i*ee,p+=i*G,a+=i*Y,i=e[11],O+=i*x,P+=i*A,z+=i*g,B+=i*R,U+=i*k,j+=i*E,H+=i*N,L+=i*F,C+=i*q,W+=i*K,D+=i*J,l+=i*$,w+=i*V,p+=i*ee,a+=i*G,d+=i*Y,i=e[12],P+=i*x,z+=i*A,B+=i*g,U+=i*R,j+=i*k,H+=i*E,L+=i*N,C+=i*F,W+=i*q,D+=i*K,l+=i*J,w+=i*$,p+=i*V,a+=i*ee,d+=i*G,m+=i*Y,i=e[13],z+=i*x,B+=i*A,U+=i*g,j+=i*R,H+=i*k,L+=i*E,C+=i*N,W+=i*F,D+=i*q,l+=i*K,w+=i*J,p+=i*$,a+=i*V,d+=i*ee,m+=i*G,_+=i*Y,i=e[14],B+=i*x,U+=i*A,j+=i*g,H+=i*R,L+=i*k,C+=i*E,W+=i*N,D+=i*F,l+=i*q,w+=i*K,p+=i*J,a+=i*$,d+=i*V,m+=i*ee,_+=i*G,y+=i*Y,i=e[15],U+=i*x,j+=i*A,H+=i*g,L+=i*R,C+=i*k,W+=i*E,D+=i*N,l+=i*F,w+=i*q,p+=i*K,a+=i*J,d+=i*$,m+=i*V,_+=i*ee,y+=i*G,h+=i*Y,s+=38*j,o+=38*H,f+=38*L,u+=38*C,c+=38*W,b+=38*D,v+=38*l,S+=38*w,I+=38*p,M+=38*a,T+=38*d,O+=38*m,P+=38*_,z+=38*y,B+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=c+n+65535,n=Math.floor(i/65536),c=i-n*65536,i=b+n+65535,n=Math.floor(i/65536),b=i-n*65536,i=v+n+65535,n=Math.floor(i/65536),v=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=M+n+65535,n=Math.floor(i/65536),M=i-n*65536,i=T+n+65535,n=Math.floor(i/65536),T=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=z+n+65535,n=Math.floor(i/65536),z=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=f,r[3]=u,r[4]=c,r[5]=b,r[6]=v,r[7]=S,r[8]=I,r[9]=M,r[10]=T,r[11]=O,r[12]=P,r[13]=z,r[14]=B,r[15]=U}function vo(r,e){bi(r,e,e)}function H8(r,e){let t=Wr();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)vo(t,t),i!==2&&i!==4&&bi(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function nu(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=Wr(),s=Wr(),o=Wr(),f=Wr(),u=Wr(),c=Wr();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,$8(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=f[0]=1;for(let I=254;I>=0;--I){let M=t[I>>>3]>>>(I&7)&1;bo(n,s,M),bo(o,f,M),ff(u,n,o),cf(n,n,o),ff(o,s,f),cf(s,s,f),vo(f,u),vo(c,n),bi(n,o,n),bi(o,s,u),ff(u,n,o),cf(n,n,o),vo(s,n),cf(o,f,c),bi(n,o,j8),ff(n,n,f),bi(o,o,n),bi(n,f,c),bi(f,s,i),vo(s,u),bo(n,s,M),bo(o,f,M)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=f[I];let b=i.subarray(32),v=i.subarray(16);H8(b,b),bi(v,v,b);let S=new Uint8Array(32);return V8(S,v),S}Qe.scalarMult=nu;function lg(r){return nu(r,dg)}Qe.scalarMultBase=lg;function pg(r){if(r.length!==Qe.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${Qe.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:lg(e),secretKey:e}}Qe.generateKeyPairFromSeed=pg;function G8(r){let e=(0,k8.randomBytes)(32,r),t=pg(e);return(0,K8.wipe)(e),t}Qe.generateKeyPair=G8;function W8(r,e,t=!1){if(r.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==Qe.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=nu(r,e);if(t){let n=0;for(let s=0;s{J8.exports={name:"elliptic",version:"6.6.0",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var Jr=Z((vg,su)=>{(function(r,e){"use strict";function t(D,l){if(!D)throw new Error(l||"Assertion failed")}function i(D,l){D.super_=l;var w=function(){};w.prototype=l.prototype,D.prototype=new w,D.prototype.constructor=D}function n(D,l,w){if(n.isBN(D))return D;this.negative=0,this.words=null,this.length=0,this.red=null,D!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(D||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=Th().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var a=0;l[0]==="-"&&(a++,this.negative=1),a=0;a-=3)m=l[a]|l[a-1]<<8|l[a-2]<<16,this.words[d]|=m<<_&67108863,this.words[d+1]=m>>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);else if(p==="le")for(a=0,d=0;a>>26-_&67108863,_+=24,_>=26&&(_-=26,d++);return this.strip()};function o(D,l){var w=D.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function f(D,l,w){var p=o(D,w);return w-1>=l&&(p|=o(D,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var a=0;a=w;a-=2)_=f(l,w,a)<=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8;else{var y=l.length-w;for(a=y%2===0?w+1:w;a=18?(d-=18,m+=1,this.words[m]|=_>>>26):d+=8}this.strip()};function u(D,l,w,p){for(var a=0,d=Math.min(D.length,w),m=l;m=49?a+=_-49+10:_>=17?a+=_-17+10:a+=_}return a}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var a=0,d=1;d<=67108863;d*=w)a++;a--,d=d/w|0;for(var m=l.length-p,_=m%a,y=Math.min(m,m-_)+p,h=0,x=p;x1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var c=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],b=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],v=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var a=0,d=0,m=0;m>>24-a&16777215,a+=2,a>=26&&(a-=26,m--),d!==0||m!==this.length-1?p=c[6-y.length]+y+p:p=y+p}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=b[l],x=v[l];p="";var A=this.clone();for(A.negative=0;!A.isZero();){var g=A.modn(x).toString(l);A=A.idivn(x),A.isZero()?p=g+p:p=c[h-g.length]+g+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var a=this.byteLength(),d=p||Math.max(1,a);t(a<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var m=w==="le",_=new l(d),y,h,x=this.clone();if(m){for(h=0;!x.isZero();h++)y=x.andln(255),x.iushrn(8),_[h]=y;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(D){for(var l=new Array(D.bitLength()),w=0;w>>a}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var a=0;al.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var a=0;a0&&(this.words[a]=~this.words[a]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,a=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,a=l):(p=l,a=this);for(var d=0,m=0;m>>26;for(;d!==0&&m>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;ml.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var a,d;p>0?(a=this,d=l):(a=l,d=this);for(var m=0,_=0;_>26,this.words[_]=w&67108863;for(;m!==0&&_>26,this.words[_]=w&67108863;if(m===0&&_>>26,A=y&67108863,g=Math.min(h,l.length-1),R=Math.max(0,h-D.length+1);R<=g;R++){var k=h-R|0;a=D.words[k]|0,d=l.words[R]|0,m=a*d+A,x+=m/67108864|0,A=m&67108863}w.words[h]=A|0,y=x|0}return y!==0?w.words[h]=y|0:w.length--,w.strip()}var M=function(l,w,p){var a=l.words,d=w.words,m=p.words,_=0,y,h,x,A=a[0]|0,g=A&8191,R=A>>>13,k=a[1]|0,E=k&8191,N=k>>>13,F=a[2]|0,q=F&8191,K=F>>>13,J=a[3]|0,$=J&8191,V=J>>>13,ee=a[4]|0,G=ee&8191,Y=ee>>>13,_r=a[5]|0,ie=_r&8191,ne=_r>>>13,xr=a[6]|0,se=xr&8191,oe=xr>>>13,Er=a[7]|0,ae=Er&8191,fe=Er>>>13,Sr=a[8]|0,ce=Sr&8191,he=Sr>>>13,Ir=a[9]|0,ue=Ir&8191,de=Ir>>>13,Mr=d[0]|0,le=Mr&8191,pe=Mr>>>13,Ar=d[1]|0,ge=Ar&8191,be=Ar>>>13,Rr=d[2]|0,ve=Rr&8191,me=Rr>>>13,Tr=d[3]|0,ye=Tr&8191,we=Tr>>>13,Dr=d[4]|0,_e=Dr&8191,xe=Dr>>>13,Pr=d[5]|0,Ee=Pr&8191,Se=Pr>>>13,Nr=d[6]|0,Ie=Nr&8191,Me=Nr>>>13,Cr=d[7]|0,Ae=Cr&8191,Re=Cr>>>13,Or=d[8]|0,Te=Or&8191,De=Or>>>13,Lr=d[9]|0,Pe=Lr&8191,Ne=Lr>>>13;p.negative=l.negative^w.negative,p.length=19,y=Math.imul(g,le),h=Math.imul(g,pe),h=h+Math.imul(R,le)|0,x=Math.imul(R,pe);var nr=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,y=Math.imul(E,le),h=Math.imul(E,pe),h=h+Math.imul(N,le)|0,x=Math.imul(N,pe),y=y+Math.imul(g,ge)|0,h=h+Math.imul(g,be)|0,h=h+Math.imul(R,ge)|0,x=x+Math.imul(R,be)|0;var Be=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Be>>>26)|0,Be&=67108863,y=Math.imul(q,le),h=Math.imul(q,pe),h=h+Math.imul(K,le)|0,x=Math.imul(K,pe),y=y+Math.imul(E,ge)|0,h=h+Math.imul(E,be)|0,h=h+Math.imul(N,ge)|0,x=x+Math.imul(N,be)|0,y=y+Math.imul(g,ve)|0,h=h+Math.imul(g,me)|0,h=h+Math.imul(R,ve)|0,x=x+Math.imul(R,me)|0;var ke=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(ke>>>26)|0,ke&=67108863,y=Math.imul($,le),h=Math.imul($,pe),h=h+Math.imul(V,le)|0,x=Math.imul(V,pe),y=y+Math.imul(q,ge)|0,h=h+Math.imul(q,be)|0,h=h+Math.imul(K,ge)|0,x=x+Math.imul(K,be)|0,y=y+Math.imul(E,ve)|0,h=h+Math.imul(E,me)|0,h=h+Math.imul(N,ve)|0,x=x+Math.imul(N,me)|0,y=y+Math.imul(g,ye)|0,h=h+Math.imul(g,we)|0,h=h+Math.imul(R,ye)|0,x=x+Math.imul(R,we)|0;var jt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(jt>>>26)|0,jt&=67108863,y=Math.imul(G,le),h=Math.imul(G,pe),h=h+Math.imul(Y,le)|0,x=Math.imul(Y,pe),y=y+Math.imul($,ge)|0,h=h+Math.imul($,be)|0,h=h+Math.imul(V,ge)|0,x=x+Math.imul(V,be)|0,y=y+Math.imul(q,ve)|0,h=h+Math.imul(q,me)|0,h=h+Math.imul(K,ve)|0,x=x+Math.imul(K,me)|0,y=y+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(N,ye)|0,x=x+Math.imul(N,we)|0,y=y+Math.imul(g,_e)|0,h=h+Math.imul(g,xe)|0,h=h+Math.imul(R,_e)|0,x=x+Math.imul(R,xe)|0;var Vt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Vt>>>26)|0,Vt&=67108863,y=Math.imul(ie,le),h=Math.imul(ie,pe),h=h+Math.imul(ne,le)|0,x=Math.imul(ne,pe),y=y+Math.imul(G,ge)|0,h=h+Math.imul(G,be)|0,h=h+Math.imul(Y,ge)|0,x=x+Math.imul(Y,be)|0,y=y+Math.imul($,ve)|0,h=h+Math.imul($,me)|0,h=h+Math.imul(V,ve)|0,x=x+Math.imul(V,me)|0,y=y+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,x=x+Math.imul(K,we)|0,y=y+Math.imul(E,_e)|0,h=h+Math.imul(E,xe)|0,h=h+Math.imul(N,_e)|0,x=x+Math.imul(N,xe)|0,y=y+Math.imul(g,Ee)|0,h=h+Math.imul(g,Se)|0,h=h+Math.imul(R,Ee)|0,x=x+Math.imul(R,Se)|0;var $t=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+($t>>>26)|0,$t&=67108863,y=Math.imul(se,le),h=Math.imul(se,pe),h=h+Math.imul(oe,le)|0,x=Math.imul(oe,pe),y=y+Math.imul(ie,ge)|0,h=h+Math.imul(ie,be)|0,h=h+Math.imul(ne,ge)|0,x=x+Math.imul(ne,be)|0,y=y+Math.imul(G,ve)|0,h=h+Math.imul(G,me)|0,h=h+Math.imul(Y,ve)|0,x=x+Math.imul(Y,me)|0,y=y+Math.imul($,ye)|0,h=h+Math.imul($,we)|0,h=h+Math.imul(V,ye)|0,x=x+Math.imul(V,we)|0,y=y+Math.imul(q,_e)|0,h=h+Math.imul(q,xe)|0,h=h+Math.imul(K,_e)|0,x=x+Math.imul(K,xe)|0,y=y+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(N,Ee)|0,x=x+Math.imul(N,Se)|0,y=y+Math.imul(g,Ie)|0,h=h+Math.imul(g,Me)|0,h=h+Math.imul(R,Ie)|0,x=x+Math.imul(R,Me)|0;var Ht=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Ht>>>26)|0,Ht&=67108863,y=Math.imul(ae,le),h=Math.imul(ae,pe),h=h+Math.imul(fe,le)|0,x=Math.imul(fe,pe),y=y+Math.imul(se,ge)|0,h=h+Math.imul(se,be)|0,h=h+Math.imul(oe,ge)|0,x=x+Math.imul(oe,be)|0,y=y+Math.imul(ie,ve)|0,h=h+Math.imul(ie,me)|0,h=h+Math.imul(ne,ve)|0,x=x+Math.imul(ne,me)|0,y=y+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(Y,ye)|0,x=x+Math.imul(Y,we)|0,y=y+Math.imul($,_e)|0,h=h+Math.imul($,xe)|0,h=h+Math.imul(V,_e)|0,x=x+Math.imul(V,xe)|0,y=y+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,x=x+Math.imul(K,Se)|0,y=y+Math.imul(E,Ie)|0,h=h+Math.imul(E,Me)|0,h=h+Math.imul(N,Ie)|0,x=x+Math.imul(N,Me)|0,y=y+Math.imul(g,Ae)|0,h=h+Math.imul(g,Re)|0,h=h+Math.imul(R,Ae)|0,x=x+Math.imul(R,Re)|0;var Gt=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Gt>>>26)|0,Gt&=67108863,y=Math.imul(ce,le),h=Math.imul(ce,pe),h=h+Math.imul(he,le)|0,x=Math.imul(he,pe),y=y+Math.imul(ae,ge)|0,h=h+Math.imul(ae,be)|0,h=h+Math.imul(fe,ge)|0,x=x+Math.imul(fe,be)|0,y=y+Math.imul(se,ve)|0,h=h+Math.imul(se,me)|0,h=h+Math.imul(oe,ve)|0,x=x+Math.imul(oe,me)|0,y=y+Math.imul(ie,ye)|0,h=h+Math.imul(ie,we)|0,h=h+Math.imul(ne,ye)|0,x=x+Math.imul(ne,we)|0,y=y+Math.imul(G,_e)|0,h=h+Math.imul(G,xe)|0,h=h+Math.imul(Y,_e)|0,x=x+Math.imul(Y,xe)|0,y=y+Math.imul($,Ee)|0,h=h+Math.imul($,Se)|0,h=h+Math.imul(V,Ee)|0,x=x+Math.imul(V,Se)|0,y=y+Math.imul(q,Ie)|0,h=h+Math.imul(q,Me)|0,h=h+Math.imul(K,Ie)|0,x=x+Math.imul(K,Me)|0,y=y+Math.imul(E,Ae)|0,h=h+Math.imul(E,Re)|0,h=h+Math.imul(N,Ae)|0,x=x+Math.imul(N,Re)|0,y=y+Math.imul(g,Te)|0,h=h+Math.imul(g,De)|0,h=h+Math.imul(R,Te)|0,x=x+Math.imul(R,De)|0;var Qi=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(Qi>>>26)|0,Qi&=67108863,y=Math.imul(ue,le),h=Math.imul(ue,pe),h=h+Math.imul(de,le)|0,x=Math.imul(de,pe),y=y+Math.imul(ce,ge)|0,h=h+Math.imul(ce,be)|0,h=h+Math.imul(he,ge)|0,x=x+Math.imul(he,be)|0,y=y+Math.imul(ae,ve)|0,h=h+Math.imul(ae,me)|0,h=h+Math.imul(fe,ve)|0,x=x+Math.imul(fe,me)|0,y=y+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,x=x+Math.imul(oe,we)|0,y=y+Math.imul(ie,_e)|0,h=h+Math.imul(ie,xe)|0,h=h+Math.imul(ne,_e)|0,x=x+Math.imul(ne,xe)|0,y=y+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(Y,Ee)|0,x=x+Math.imul(Y,Se)|0,y=y+Math.imul($,Ie)|0,h=h+Math.imul($,Me)|0,h=h+Math.imul(V,Ie)|0,x=x+Math.imul(V,Me)|0,y=y+Math.imul(q,Ae)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(K,Ae)|0,x=x+Math.imul(K,Re)|0,y=y+Math.imul(E,Te)|0,h=h+Math.imul(E,De)|0,h=h+Math.imul(N,Te)|0,x=x+Math.imul(N,De)|0,y=y+Math.imul(g,Pe)|0,h=h+Math.imul(g,Ne)|0,h=h+Math.imul(R,Pe)|0,x=x+Math.imul(R,Ne)|0;var en=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(en>>>26)|0,en&=67108863,y=Math.imul(ue,ge),h=Math.imul(ue,be),h=h+Math.imul(de,ge)|0,x=Math.imul(de,be),y=y+Math.imul(ce,ve)|0,h=h+Math.imul(ce,me)|0,h=h+Math.imul(he,ve)|0,x=x+Math.imul(he,me)|0,y=y+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(fe,ye)|0,x=x+Math.imul(fe,we)|0,y=y+Math.imul(se,_e)|0,h=h+Math.imul(se,xe)|0,h=h+Math.imul(oe,_e)|0,x=x+Math.imul(oe,xe)|0,y=y+Math.imul(ie,Ee)|0,h=h+Math.imul(ie,Se)|0,h=h+Math.imul(ne,Ee)|0,x=x+Math.imul(ne,Se)|0,y=y+Math.imul(G,Ie)|0,h=h+Math.imul(G,Me)|0,h=h+Math.imul(Y,Ie)|0,x=x+Math.imul(Y,Me)|0,y=y+Math.imul($,Ae)|0,h=h+Math.imul($,Re)|0,h=h+Math.imul(V,Ae)|0,x=x+Math.imul(V,Re)|0,y=y+Math.imul(q,Te)|0,h=h+Math.imul(q,De)|0,h=h+Math.imul(K,Te)|0,x=x+Math.imul(K,De)|0,y=y+Math.imul(E,Pe)|0,h=h+Math.imul(E,Ne)|0,h=h+Math.imul(N,Pe)|0,x=x+Math.imul(N,Ne)|0;var tn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(tn>>>26)|0,tn&=67108863,y=Math.imul(ue,ve),h=Math.imul(ue,me),h=h+Math.imul(de,ve)|0,x=Math.imul(de,me),y=y+Math.imul(ce,ye)|0,h=h+Math.imul(ce,we)|0,h=h+Math.imul(he,ye)|0,x=x+Math.imul(he,we)|0,y=y+Math.imul(ae,_e)|0,h=h+Math.imul(ae,xe)|0,h=h+Math.imul(fe,_e)|0,x=x+Math.imul(fe,xe)|0,y=y+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,x=x+Math.imul(oe,Se)|0,y=y+Math.imul(ie,Ie)|0,h=h+Math.imul(ie,Me)|0,h=h+Math.imul(ne,Ie)|0,x=x+Math.imul(ne,Me)|0,y=y+Math.imul(G,Ae)|0,h=h+Math.imul(G,Re)|0,h=h+Math.imul(Y,Ae)|0,x=x+Math.imul(Y,Re)|0,y=y+Math.imul($,Te)|0,h=h+Math.imul($,De)|0,h=h+Math.imul(V,Te)|0,x=x+Math.imul(V,De)|0,y=y+Math.imul(q,Pe)|0,h=h+Math.imul(q,Ne)|0,h=h+Math.imul(K,Pe)|0,x=x+Math.imul(K,Ne)|0;var rn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(rn>>>26)|0,rn&=67108863,y=Math.imul(ue,ye),h=Math.imul(ue,we),h=h+Math.imul(de,ye)|0,x=Math.imul(de,we),y=y+Math.imul(ce,_e)|0,h=h+Math.imul(ce,xe)|0,h=h+Math.imul(he,_e)|0,x=x+Math.imul(he,xe)|0,y=y+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(fe,Ee)|0,x=x+Math.imul(fe,Se)|0,y=y+Math.imul(se,Ie)|0,h=h+Math.imul(se,Me)|0,h=h+Math.imul(oe,Ie)|0,x=x+Math.imul(oe,Me)|0,y=y+Math.imul(ie,Ae)|0,h=h+Math.imul(ie,Re)|0,h=h+Math.imul(ne,Ae)|0,x=x+Math.imul(ne,Re)|0,y=y+Math.imul(G,Te)|0,h=h+Math.imul(G,De)|0,h=h+Math.imul(Y,Te)|0,x=x+Math.imul(Y,De)|0,y=y+Math.imul($,Pe)|0,h=h+Math.imul($,Ne)|0,h=h+Math.imul(V,Pe)|0,x=x+Math.imul(V,Ne)|0;var nn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(nn>>>26)|0,nn&=67108863,y=Math.imul(ue,_e),h=Math.imul(ue,xe),h=h+Math.imul(de,_e)|0,x=Math.imul(de,xe),y=y+Math.imul(ce,Ee)|0,h=h+Math.imul(ce,Se)|0,h=h+Math.imul(he,Ee)|0,x=x+Math.imul(he,Se)|0,y=y+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Me)|0,h=h+Math.imul(fe,Ie)|0,x=x+Math.imul(fe,Me)|0,y=y+Math.imul(se,Ae)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(oe,Ae)|0,x=x+Math.imul(oe,Re)|0,y=y+Math.imul(ie,Te)|0,h=h+Math.imul(ie,De)|0,h=h+Math.imul(ne,Te)|0,x=x+Math.imul(ne,De)|0,y=y+Math.imul(G,Pe)|0,h=h+Math.imul(G,Ne)|0,h=h+Math.imul(Y,Pe)|0,x=x+Math.imul(Y,Ne)|0;var sn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(sn>>>26)|0,sn&=67108863,y=Math.imul(ue,Ee),h=Math.imul(ue,Se),h=h+Math.imul(de,Ee)|0,x=Math.imul(de,Se),y=y+Math.imul(ce,Ie)|0,h=h+Math.imul(ce,Me)|0,h=h+Math.imul(he,Ie)|0,x=x+Math.imul(he,Me)|0,y=y+Math.imul(ae,Ae)|0,h=h+Math.imul(ae,Re)|0,h=h+Math.imul(fe,Ae)|0,x=x+Math.imul(fe,Re)|0,y=y+Math.imul(se,Te)|0,h=h+Math.imul(se,De)|0,h=h+Math.imul(oe,Te)|0,x=x+Math.imul(oe,De)|0,y=y+Math.imul(ie,Pe)|0,h=h+Math.imul(ie,Ne)|0,h=h+Math.imul(ne,Pe)|0,x=x+Math.imul(ne,Ne)|0;var on=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(on>>>26)|0,on&=67108863,y=Math.imul(ue,Ie),h=Math.imul(ue,Me),h=h+Math.imul(de,Ie)|0,x=Math.imul(de,Me),y=y+Math.imul(ce,Ae)|0,h=h+Math.imul(ce,Re)|0,h=h+Math.imul(he,Ae)|0,x=x+Math.imul(he,Re)|0,y=y+Math.imul(ae,Te)|0,h=h+Math.imul(ae,De)|0,h=h+Math.imul(fe,Te)|0,x=x+Math.imul(fe,De)|0,y=y+Math.imul(se,Pe)|0,h=h+Math.imul(se,Ne)|0,h=h+Math.imul(oe,Pe)|0,x=x+Math.imul(oe,Ne)|0;var an=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(an>>>26)|0,an&=67108863,y=Math.imul(ue,Ae),h=Math.imul(ue,Re),h=h+Math.imul(de,Ae)|0,x=Math.imul(de,Re),y=y+Math.imul(ce,Te)|0,h=h+Math.imul(ce,De)|0,h=h+Math.imul(he,Te)|0,x=x+Math.imul(he,De)|0,y=y+Math.imul(ae,Pe)|0,h=h+Math.imul(ae,Ne)|0,h=h+Math.imul(fe,Pe)|0,x=x+Math.imul(fe,Ne)|0;var fn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(fn>>>26)|0,fn&=67108863,y=Math.imul(ue,Te),h=Math.imul(ue,De),h=h+Math.imul(de,Te)|0,x=Math.imul(de,De),y=y+Math.imul(ce,Pe)|0,h=h+Math.imul(ce,Ne)|0,h=h+Math.imul(he,Pe)|0,x=x+Math.imul(he,Ne)|0;var cn=(_+y|0)+((h&8191)<<13)|0;_=(x+(h>>>13)|0)+(cn>>>26)|0,cn&=67108863,y=Math.imul(ue,Pe),h=Math.imul(ue,Ne),h=h+Math.imul(de,Pe)|0,x=Math.imul(de,Ne);var hn=(_+y|0)+((h&8191)<<13)|0;return _=(x+(h>>>13)|0)+(hn>>>26)|0,hn&=67108863,m[0]=nr,m[1]=Be,m[2]=ke,m[3]=jt,m[4]=Vt,m[5]=$t,m[6]=Ht,m[7]=Gt,m[8]=Qi,m[9]=en,m[10]=tn,m[11]=rn,m[12]=nn,m[13]=sn,m[14]=on,m[15]=an,m[16]=fn,m[17]=cn,m[18]=hn,_!==0&&(m[19]=_,p.length++),p};Math.imul||(M=I);function T(D,l,w){w.negative=l.negative^D.negative,w.length=D.length+l.length;for(var p=0,a=0,d=0;d>>26)|0,a+=m>>>26,m&=67108863}w.words[d]=_,p=m,m=a}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(D,l,w){var p=new P;return p.mulp(D,l,w)}n.prototype.mulTo=function(l,w){var p,a=this.length+l.length;return this.length===10&&l.length===10?p=M(this,l,w):a<63?p=I(this,l,w):a<1024?p=T(this,l,w):p=O(this,l,w),p};function P(D,l){this.x=D,this.y=l}P.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,a=0;a>=1;return a},P.prototype.permute=function(l,w,p,a,d,m){for(var _=0;_>>1)d++;return 1<>>13,p[2*m+1]=d&8191,d=d>>>13;for(m=2*w;m>=26,w+=a/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,a=0;a=0);var w=l%26,p=(l-w)/26,a=67108863>>>26-w<<26-w,d;if(w!==0){var m=0;for(d=0;d>>26-w}m&&(this.words[d]=m,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var a;w?a=(w-w%26)/26:a=0;var d=l%26,m=Math.min((l-d)/26,this.length),_=67108863^67108863>>>d<m)for(this.length-=m,h=0;h=0&&(x!==0||h>=a);h--){var A=this.words[h]|0;this.words[h]=x<<26-d|A>>>d,x=A&_}return y&&x!==0&&(y.words[y.length++]=x),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,a=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var a=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(y/67108864|0),this.words[d+p]=m&67108863}for(;d>26,this.words[d+p]=m&67108863;if(_===0)return this.strip();for(t(_===-1),_=0,d=0;d>26,this.words[d]=m&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,a=this.clone(),d=l,m=d.words[d.length-1]|0,_=this._countBits(m);p=26-_,p!==0&&(d=d.ushln(p),a.iushln(p),m=d.words[d.length-1]|0);var y=a.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=y+1,h.words=new Array(h.length);for(var x=0;x=0;g--){var R=(a.words[d.length+g]|0)*67108864+(a.words[d.length+g-1]|0);for(R=Math.min(R/m|0,67108863),a._ishlnsubmul(d,R,g);a.negative!==0;)R--,a.negative=0,a._ishlnsubmul(d,1,g),a.isZero()||(a.negative^=1);h&&(h.words[g]=R)}return h&&h.strip(),a.strip(),w!=="div"&&p!==0&&a.iushrn(p),{div:h||null,mod:a}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var a,d,m;return this.negative!==0&&l.negative===0?(m=this.neg().divmod(l,w),w!=="mod"&&(a=m.div.neg()),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:a,mod:d}):this.negative===0&&l.negative!==0?(m=this.divmod(l.neg(),w),w!=="mod"&&(a=m.div.neg()),{div:a,mod:m.mod}):this.negative&l.negative?(m=this.neg().divmod(l.neg(),w),w!=="div"&&(d=m.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:m.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,a=l.ushrn(1),d=l.andln(1),m=p.cmp(a);return m<0||d===1&&m===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,a=this.length-1;a>=0;a--)p=(w*p+(this.words[a]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var a=(this.words[p]|0)+w*67108864;this.words[p]=a/l|0,w=a%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=new n(0),_=new n(1),y=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++y;for(var h=p.clone(),x=w.clone();!w.isZero();){for(var A=0,g=1;!(w.words[0]&g)&&A<26;++A,g<<=1);if(A>0)for(w.iushrn(A);A-- >0;)(a.isOdd()||d.isOdd())&&(a.iadd(h),d.isub(x)),a.iushrn(1),d.iushrn(1);for(var R=0,k=1;!(p.words[0]&k)&&R<26;++R,k<<=1);if(R>0)for(p.iushrn(R);R-- >0;)(m.isOdd()||_.isOdd())&&(m.iadd(h),_.isub(x)),m.iushrn(1),_.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(m),d.isub(_)):(p.isub(w),m.isub(a),_.isub(d))}return{a:m,b:_,gcd:p.iushln(y)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var a=new n(1),d=new n(0),m=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var _=0,y=1;!(w.words[0]&y)&&_<26;++_,y<<=1);if(_>0)for(w.iushrn(_);_-- >0;)a.isOdd()&&a.iadd(m),a.iushrn(1);for(var h=0,x=1;!(p.words[0]&x)&&h<26;++h,x<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(m),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),a.isub(d)):(p.isub(w),d.isub(a))}var A;return w.cmpn(1)===0?A=a:A=d,A.cmpn(0)<0&&A.iadd(l),A},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var a=0;w.isEven()&&p.isEven();a++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var m=w;w=p,p=m}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(a)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,a=1<>>26,_&=67108863,this.words[m]=_}return d!==0&&(this.words[m]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var a=this.words[0]|0;p=a===l?0:al.length)return 1;if(this.length=0;p--){var a=this.words[p]|0,d=l.words[p]|0;if(a!==d){ad&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new C(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var z={k256:null,p224:null,p192:null,p25519:null};function B(D,l){this.name=D,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}B.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},B.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var a=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},B.prototype.split=function(l,w){l.iushrn(this.n,0,w)},B.prototype.imulK=function(l){return l.imul(this.k)};function U(){B.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(U,B),U.prototype.split=function(l,w){for(var p=4194303,a=Math.min(l.length,9),d=0;d>>22,m=_}m>>>=22,l.words[d-10]=m,m===0&&l.length>10?l.length-=10:l.length-=9},U.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=a}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(z[l])return z[l];var w;if(l==="k256")w=new U;else if(l==="p224")w=new j;else if(l==="p192")w=new H;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return z[l]=w,w};function C(D){if(typeof D=="string"){var l=n._prime(D);this.m=l.p,this.prime=l}else t(D.gtn(1),"modulus must be greater than 1"),this.m=D,this.prime=null}C.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},C.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},C.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},C.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},C.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},C.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},C.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},C.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},C.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},C.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},C.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},C.prototype.isqr=function(l){return this.imul(l,l.clone())},C.prototype.sqr=function(l){return this.mul(l,l)},C.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var a=this.m.subn(1),d=0;!a.isZero()&&a.andln(1)===0;)d++,a.iushrn(1);t(!a.isZero());var m=new n(1).toRed(this),_=m.redNeg(),y=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,y).cmp(_)!==0;)h.redIAdd(_);for(var x=this.pow(h,a),A=this.pow(l,a.addn(1).iushrn(1)),g=this.pow(l,a),R=d;g.cmp(m)!==0;){for(var k=g,E=0;k.cmp(m)!==0;E++)k=k.redSqr();t(E=0;d--){for(var x=w.words[d],A=h-1;A>=0;A--){var g=x>>A&1;if(m!==a[0]&&(m=this.sqr(m)),g===0&&_===0){y=0;continue}_<<=1,_|=g,y++,!(y!==p&&(d!==0||A!==0))&&(m=this.mul(m,a[_]),y=0,_=0)}h=26}return m},C.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},C.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(D){C.call(this,D),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,C),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),a=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(a).iushrn(this.shift),m=d;return d.cmp(this.m)>=0?m=d.isub(this.m):d.cmpn(0)<0&&(m=d.iadd(this.m)),m._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof su>"u"||su,vg)});var ou=Z(wg=>{"use strict";var hf=wg;function Y8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}hf.toArray=Y8;function mg(r){return r.length===1?"0"+r:r}hf.zero2=mg;function yg(r){for(var e="",t=0;t{"use strict";var dr=_g,X8=Jr(),Z8=Pi(),uf=ou();dr.assert=Z8;dr.toArray=uf.toArray;dr.zero2=uf.zero2;dr.toHex=uf.toHex;dr.encode=uf.encode;function Q8(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?f=(s>>1)-u:f=u,o.isubn(f)):f=0,i[n]=f,o.iushrn(1)}return i}dr.getNAF=Q8;function e4(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,f=e.andln(3)+n&3;o===3&&(o=-1),f===3&&(f=-1);var u;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&f===2?u=-o:u=o):u=0,t[0].push(u);var c;f&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?c=-f:c=f):c=0,t[1].push(c),2*i===u+1&&(i=1-i),2*n===c+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}dr.getJSF=e4;function t4(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}dr.cachedProperty=t4;function r4(r){return typeof r=="string"?dr.toArray(r,"hex"):r}dr.parseBytes=r4;function i4(r){return new X8(r,"hex","le")}dr.intFromLE=i4});var hu=Z((KR,cu)=>{var au;cu.exports=function(e){return au||(au=new Fi(null)),au.generate(e)};function Fi(r){this.rand=r}cu.exports.Rand=Fi;Fi.prototype.generate=function(e){return this._rand(e)};Fi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var En=Jr(),mo=Bt(),df=mo.getNAF,n4=mo.getJSF,lf=mo.assert;function qi(r,e){this.type=r,this.p=new En(e.p,16),this.red=e.prime?En.red(e.prime):En.mont(this.p),this.zero=new En(0).toRed(this.red),this.one=new En(1).toRed(this.red),this.two=new En(2).toRed(this.red),this.n=e.n&&new En(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}xg.exports=qi;qi.prototype.point=function(){throw new Error("Not implemented")};qi.prototype.validate=function(){throw new Error("Not implemented")};qi.prototype._fixedNafMul=function(e,t){lf(e.precomputed);var i=e._getDoubles(),n=df(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];lf(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};qi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=df(i[M],o[M],this._bitLength),u[T]=df(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=n4(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Qt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var s4=Bt(),et=Jr(),uu=co(),ps=yo(),o4=s4.assert;function er(r){ps.call(this,"short",r),this.a=new et(r.a,16).toRed(this.red),this.b=new et(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}uu(er,ps);Eg.exports=er;er.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new et(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new et(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],o4(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(f){return{a:new et(f.a,16),b:new et(f.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};er.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:et.mont(e),i=new et(2).toRed(t).redInvm(),n=i.redNeg(),s=new et(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),f=n.redSub(s).fromRed();return[o,f]};er.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new et(1),o=new et(0),f=new et(0),u=new et(1),c,b,v,S,I,M,T,O=0,P,z;i.cmpn(0)!==0;){var B=n.div(i);P=n.sub(B.mul(i)),z=f.sub(B.mul(s));var U=u.sub(B.mul(o));if(!v&&P.cmp(t)<0)c=T.neg(),b=s,v=P.neg(),S=z;else if(v&&++O===2)break;T=P,n=i,i=P,f=s,s=z,u=o,o=U}I=P.neg(),M=z;var j=v.sqr().add(S.sqr()),H=I.sqr().add(M.sqr());return H.cmp(j)>=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};er.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};er.prototype.pointFromX=function(e,t){e=new et(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};er.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};er.prototype._endoWnafMulAdd=function(e,t,i){for(var n=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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ct.prototype.getX=function(){return this.x.fromRed()};ct.prototype.getY=function(){return this.y.fromRed()};ct.prototype.mul=function(e){return e=new et(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,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ct.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,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 t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};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(r,e,t,i){ps.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new et(0)):(this.x=new et(e,16),this.y=new et(t,16),this.z=new et(i,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}uu(bt,ps.BasePoint);er.prototype.jpoint=function(e,t,i){return new bt(this,e,t,i)};bt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};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 t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};bt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};bt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};bt.prototype.inspect=function(){return this.isInfinity()?"":""};bt.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Ag=Z(($R,Mg)=>{"use strict";var gs=Jr(),Ig=co(),pf=yo(),a4=Bt();function bs(r){pf.call(this,"mont",r),this.a=new gs(r.a,16).toRed(this.red),this.b=new gs(r.b,16).toRed(this.red),this.i4=new gs(4).toRed(this.red).redInvm(),this.two=new gs(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Ig(bs,pf);Mg.exports=bs;bs.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function ht(r,e,t){pf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new gs(e,16),this.z=new gs(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Ig(ht,pf.BasePoint);bs.prototype.decodePoint=function(e,t){return this.point(a4.toArray(e,t),1)};bs.prototype.point=function(e,t){return new ht(this,e,t)};bs.prototype.pointFromJSON=function(e){return ht.fromJSON(this,e)};ht.prototype.precompute=function(){};ht.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};ht.fromJSON=function(e,t){return new ht(e,t[0],t[1]||e.one)};ht.prototype.inspect=function(){return this.isInfinity()?"":""};ht.prototype.isInfinity=function(){return this.z.cmpn(0)===0};ht.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),f=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,f)};ht.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),f=o.redMul(i),u=s.redMul(n),c=t.z.redMul(f.redAdd(u).redSqr()),b=t.x.redMul(f.redISub(u).redSqr());return this.curve.point(c,b)};ht.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var f=o.length-1;f>=0;f--)o[f]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};ht.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};ht.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};ht.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};ht.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Dg=Z((HR,Tg)=>{"use strict";var f4=Bt(),vi=Jr(),Rg=co(),gf=yo(),c4=f4.assert;function Yr(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,gf.call(this,"edwards",r),this.a=new vi(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new vi(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new vi(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),c4(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Rg(Yr,gf);Tg.exports=Yr;Yr.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};Yr.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};Yr.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};Yr.prototype.pointFromX=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var u=f.fromRed().isOdd();return(t&&!u||!t&&u)&&(f=f.redNeg()),this.point(e,f)};Yr.prototype.pointFromY=function(e,t){e=new vi(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var f=o.redSqrt();if(f.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return f.fromRed().isOdd()!==t&&(f=f.redNeg()),this.point(f,e)};Yr.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ge(r,e,t,i,n){gf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new vi(e,16),this.y=new vi(t,16),this.z=i?new vi(i,16):this.curve.one,this.t=n&&new vi(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.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Rg(Ge,gf.BasePoint);Yr.prototype.pointFromJSON=function(e){return Ge.fromJSON(this,e)};Yr.prototype.point=function(e,t,i,n){return new Ge(this,e,t,i,n)};Ge.fromJSON=function(e,t){return new Ge(e,t[0],t[1],t[2])};Ge.prototype.inspect=function(){return this.isInfinity()?"":""};Ge.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ge.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),f=o.redSub(i),u=n.redSub(t),c=s.redMul(f),b=o.redMul(u),v=s.redMul(u),S=f.redMul(o);return this.curve.point(c,b,S,v)};Ge.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,f,u,c;if(this.curve.twisted){f=this.curve._mulA(t);var b=f.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(b.redSub(this.curve.two)),s=b.redMul(f.redSub(i)),o=b.redSqr().redSub(b).redSub(b)):(u=this.z.redSqr(),c=b.redSub(u).redISub(u),n=e.redSub(t).redISub(i).redMul(c),s=b.redMul(f.redSub(i)),o=b.redMul(c))}else f=t.redAdd(i),u=this.curve._mulC(this.z).redSqr(),c=f.redSub(u).redSub(u),n=this.curve._mulC(e.redISub(f)).redMul(c),s=this.curve._mulC(f).redMul(t.redISub(i)),o=f.redMul(c);return this.curve.point(n,s,o)};Ge.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ge.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),f=s.redSub(n),u=s.redAdd(n),c=i.redAdd(t),b=o.redMul(f),v=u.redMul(c),S=o.redMul(c),I=f.redMul(u);return this.curve.point(b,v,I,S)};Ge.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),f=i.redSub(o),u=i.redAdd(o),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),b=t.redMul(f).redMul(c),v,S;return this.curve.twisted?(v=t.redMul(u).redMul(s.redSub(this.curve._mulA(n))),S=f.redMul(u)):(v=t.redMul(u).redMul(s.redSub(n)),S=this.curve._mulC(f).redMul(u)),this.curve.point(b,v,S)};Ge.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ge.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ge.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ge.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ge.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ge.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ge.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ge.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ge.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ge.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ge.prototype.toP=Ge.prototype.normalize;Ge.prototype.mixedAdd=Ge.prototype.add});var du=Z(Pg=>{"use strict";var bf=Pg;bf.base=yo();bf.short=Sg();bf.mont=Ag();bf.edwards=Dg()});var Cg=Z((WR,Ng)=>{Ng.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var vf=Z(Fg=>{"use strict";var pu=Fg,Ui=lo(),lu=du(),h4=Bt(),Og=h4.assert;function Lg(r){r.type==="short"?this.curve=new lu.short(r):r.type==="edwards"?this.curve=new lu.edwards(r):this.curve=new lu.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,Og(this.g.validate(),"Invalid curve"),Og(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}pu.PresetCurve=Lg;function zi(r,e){Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,get:function(){var t=new Lg(e);return Object.defineProperty(pu,r,{configurable:!0,enumerable:!0,value:t}),t}})}zi("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:Ui.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});zi("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:Ui.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});zi("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:Ui.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});zi("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:Ui.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"]});zi("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:Ui.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"]});zi("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:Ui.sha256,gRed:!1,g:["9"]});zi("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:Ui.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var gu;try{gu=Cg()}catch{gu=void 0}zi("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:Ui.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",gu]})});var zg=Z((YR,Ug)=>{"use strict";var u4=lo(),Sn=ou(),qg=Pi();function Bi(r){if(!(this instanceof Bi))return new Bi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Sn.toArray(r.entropy,r.entropyEnc||"hex"),t=Sn.toArray(r.nonce,r.nonceEnc||"hex"),i=Sn.toArray(r.pers,r.persEnc||"hex");qg(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}Ug.exports=Bi;Bi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);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(i||[])),this._reseed=1};Bi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Sn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var d4=Jr(),l4=Bt(),bu=l4.assert;function St(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}Bg.exports=St;St.fromPublic=function(e,t,i){return t instanceof St?t:new St(e,{pub:t,pubEnc:i})};St.fromPrivate=function(e,t,i){return t instanceof St?t:new St(e,{priv:t,privEnc:i})};St.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};St.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};St.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};St.prototype._importPrivate=function(e,t){this.priv=new d4(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};St.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?bu(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&bu(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};St.prototype.derive=function(e){return e.validate()||bu(e.validate(),"public point not validated"),e.mul(this.priv).getX()};St.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};St.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)};St.prototype.inspect=function(){return""}});var Vg=Z((ZR,jg)=>{"use strict";var mf=Jr(),yu=Bt(),p4=yu.assert;function yf(r,e){if(r instanceof yf)return r;this._importDER(r,e)||(p4(r.r&&r.s,"Signature without r or s"),this.r=new mf(r.r,16),this.s=new mf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}jg.exports=yf;function g4(){this.place=0}function vu(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function Kg(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}yf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=Kg(t),i=Kg(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];mu(n,t.length),n=n.concat(t),n.push(2),mu(n,i.length);var s=n.concat(i),o=[48];return mu(o,s.length),o=o.concat(s),yu.encode(o,e)}});var Wg=Z((QR,Gg)=>{"use strict";var mi=Jr(),$g=zg(),b4=Bt(),wu=vf(),v4=hu(),Hg=b4.assert,_u=kg(),wf=Vg();function tr(r){if(!(this instanceof tr))return new tr(r);typeof r=="string"&&(Hg(Object.prototype.hasOwnProperty.call(wu,r),"Unknown curve "+r),r=wu[r]),r instanceof wu.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}Gg.exports=tr;tr.prototype.keyPair=function(e){return new _u(this,e)};tr.prototype.keyFromPrivate=function(e,t){return _u.fromPrivate(this,e,t)};tr.prototype.keyFromPublic=function(e,t){return _u.fromPublic(this,e,t)};tr.prototype.genKeyPair=function(e){e||(e={});for(var t=new $g({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v4(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new mi(2));;){var s=new mi(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};tr.prototype._truncateToN=function(e,t,i){var n;if(mi.isBN(e)||typeof e=="number")e=new mi(e,16),n=e.byteLength();else if(typeof e=="object")n=e.length,e=new mi(e,16);else{var s=e.toString();n=s.length+1>>>1,e=new mi(s,16)}typeof i!="number"&&(i=n*8);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};tr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength);for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new $g({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new mi(1)),b=0;;b++){var v=n.k?n.k(b):new mi(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new wf({r:M,s:T,recoveryParam:O})}}}}}};tr.prototype.verify=function(e,t,i,n,s){s||(s={}),e=this._truncateToN(e,!1,s.msgBitLength),i=this.keyFromPublic(i,n),t=new wf(t,"hex");var o=t.r,f=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0||f.cmpn(1)<0||f.cmp(this.n)>=0)return!1;var u=f.invm(this.n),c=u.mul(e).umod(this.n),b=u.mul(o).umod(this.n),v;return this.curve._maxwellTrick?(v=this.g.jmulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.eqXToP(o)):(v=this.g.mulAdd(c,i.getPublic(),b),v.isInfinity()?!1:v.getX().umod(this.n).cmp(o)===0)};tr.prototype.recoverPubKey=function(r,e,t,i){Hg((3&t)===t,"The recovery param is more than two bits"),e=new wf(e,i);var n=this.n,s=new mi(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};tr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new wf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var Zg=Z((eT,Xg)=>{"use strict";var wo=Bt(),Yg=wo.assert,Jg=wo.parseBytes,vs=wo.cachedProperty;function ut(r,e){this.eddsa=r,this._secret=Jg(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=Jg(e.pub)}ut.fromPublic=function(e,t){return t instanceof ut?t:new ut(e,{pub:t})};ut.fromSecret=function(e,t){return t instanceof ut?t:new ut(e,{secret:t})};ut.prototype.secret=function(){return this._secret};vs(ut,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});vs(ut,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});vs(ut,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});vs(ut,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});vs(ut,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});vs(ut,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});ut.prototype.sign=function(e){return Yg(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};ut.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};ut.prototype.getSecret=function(e){return Yg(this._secret,"KeyPair is public only"),wo.encode(this.secret(),e)};ut.prototype.getPublic=function(e){return wo.encode(this.pubBytes(),e)};Xg.exports=ut});var tb=Z((tT,eb)=>{"use strict";var m4=Jr(),_f=Bt(),Qg=_f.assert,xf=_f.cachedProperty,y4=_f.parseBytes;function In(r,e){this.eddsa=r,typeof e!="object"&&(e=y4(e)),Array.isArray(e)&&(Qg(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),Qg(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof m4&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}xf(In,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});xf(In,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});xf(In,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});xf(In,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});In.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};In.prototype.toHex=function(){return _f.encode(this.toBytes(),"hex").toUpperCase()};eb.exports=In});var ob=Z((rT,sb)=>{"use strict";var w4=lo(),_4=vf(),ms=Bt(),x4=ms.assert,ib=ms.parseBytes,nb=Zg(),rb=tb();function Lt(r){if(x4(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Lt))return new Lt(r);r=_4[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=w4.sha512}sb.exports=Lt;Lt.prototype.sign=function(e,t){e=ib(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),f=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),u=n.add(f).umod(this.curve.n);return this.makeSignature({R:s,S:u,Rencoded:o})};Lt.prototype.verify=function(e,t,i){if(e=ib(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),f=t.R().add(n.pub().mul(s));return f.eq(o)};Lt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Mn=ab;Mn.version=bg().version;Mn.utils=Bt();Mn.rand=hu();Mn.curve=du();Mn.curves=vf();Mn.ec=Wg();Mn.eddsa=ob()});var vv=Z($i=>{"use strict";Object.defineProperty($i,"__esModule",{value:!0});$i.isBrowserCryptoAvailable=$i.getSubtleCrypto=$i.getBrowerCrypto=void 0;function Wu(){return window?.crypto||window?.msCrypto||{}}$i.getBrowerCrypto=Wu;function bv(){let r=Wu();return r.subtle||r.webkitSubtle}$i.getSubtleCrypto=bv;function U_(){return!!Wu()&&!!bv()}$i.isBrowserCryptoAvailable=U_});var wv=Z(Hi=>{"use strict";Object.defineProperty(Hi,"__esModule",{value:!0});Hi.isBrowser=Hi.isNode=Hi.isReactNative=void 0;function mv(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Hi.isReactNative=mv;function yv(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Hi.isNode=yv;function z_(){return!mv()&&!yv()}Hi.isBrowser=z_});var Ju=Z(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});var _v=(zn(),qs(Un));_v.__exportStar(vv(),Lf);_v.__exportStar(wv(),Lf)});var Rv=Z((UT,Av)=>{"use strict";Av.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var dm=Z((qo,Ns)=>{var X_=200,cd="__lodash_hash_undefined__",Jf=1,jv=2,Vv=9007199254740991,Kf="[object Arguments]",rd="[object Array]",Z_="[object AsyncFunction]",$v="[object Boolean]",Hv="[object Date]",Gv="[object Error]",Wv="[object Function]",Q_="[object GeneratorFunction]",jf="[object Map]",Jv="[object Number]",ex="[object Null]",Ps="[object Object]",Nv="[object Promise]",tx="[object Proxy]",Yv="[object RegExp]",Vf="[object Set]",Xv="[object String]",rx="[object Symbol]",ix="[object Undefined]",id="[object WeakMap]",Zv="[object ArrayBuffer]",$f="[object DataView]",nx="[object Float32Array]",sx="[object Float64Array]",ox="[object Int8Array]",ax="[object Int16Array]",fx="[object Int32Array]",cx="[object Uint8Array]",hx="[object Uint8ClampedArray]",ux="[object Uint16Array]",dx="[object Uint32Array]",lx=/[\\^$.*+?()[\]{}|]/g,px=/^\[object .+?Constructor\]$/,gx=/^(?:0|[1-9]\d*)$/,Je={};Je[nx]=Je[sx]=Je[ox]=Je[ax]=Je[fx]=Je[cx]=Je[hx]=Je[ux]=Je[dx]=!0;Je[Kf]=Je[rd]=Je[Zv]=Je[$v]=Je[$f]=Je[Hv]=Je[Gv]=Je[Wv]=Je[jf]=Je[Jv]=Je[Ps]=Je[Yv]=Je[Vf]=Je[Xv]=Je[id]=!1;var Qv=typeof window=="object"&&window&&window.Object===Object&&window,bx=typeof self=="object"&&self&&self.Object===Object&&self,xi=Qv||bx||Function("return this")(),em=typeof qo=="object"&&qo&&!qo.nodeType&&qo,Cv=em&&typeof Ns=="object"&&Ns&&!Ns.nodeType&&Ns,tm=Cv&&Cv.exports===em,Qu=tm&&Qv.process,Ov=function(){try{return Qu&&Qu.binding&&Qu.binding("util")}catch{}}(),Lv=Ov&&Ov.isTypedArray;function vx(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function Gx(r,e){var t=this.__data__,i=Xf(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}Ei.prototype.clear=jx;Ei.prototype.delete=Vx;Ei.prototype.get=$x;Ei.prototype.has=Hx;Ei.prototype.set=Gx;function On(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ef))return!1;var c=s.get(r);if(c&&s.get(e))return c==e;var b=-1,v=!0,S=t&jv?new Gf:void 0;for(s.set(r,e),s.set(e,r);++b-1&&r%1==0&&r-1&&r%1==0&&r<=Vv}function hm(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function Bo(r){return r!=null&&typeof r=="object"}var um=Lv?_x(Lv):hE;function SE(r){return xE(r)?oE(r):uE(r)}function IE(){return[]}function ME(){return!1}Ns.exports=EE});var Si=qe(un());var Pl=qe(un()),sa=qe(jn());var sr=class{};var mc=class extends sr{constructor(e){super()}},Dl=sa.FIVE_SECONDS,dn={pulse:"heartbeat_pulse"},na=class r extends mc{constructor(e){super(e),this.events=new Pl.EventEmitter,this.interval=Dl,this.interval=e?.interval||Dl}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,sa.toMiliseconds)(this.interval))}pulse(){this.events.emit(dn.pulse)}};var r2=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,i2=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,n2=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function s2(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){o2(r);return}return e}function o2(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Bs(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!n2.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(r2.test(r)||i2.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,s2)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function a2(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function ot(r,...e){try{return a2(r(...e))}catch(t){return Promise.reject(t)}}function f2(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function c2(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function ks(r){if(f2(r))return String(r);if(c2(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return ks(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Nl(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var yc="base64:";function Cl(r){if(typeof r=="string")return r;Nl();let e=Buffer.from(r).toString("base64");return yc+e}function Ol(r){return typeof r!="string"||!r.startsWith(yc)?r:(Nl(),Buffer.from(r.slice(yc.length),"base64"))}function Pt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Ll(...r){return Pt(r.join(":"))}function Ks(r){return r=Pt(r),r?r+":":""}var h2="memory",u2=()=>{let r=new Map;return{name:h2,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function Ul(r={}){let e={mounts:{"":r.driver||u2()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(let b of e.mountpoints)if(c.startsWith(b))return{base:b,relativeKey:c.slice(b.length),driver:e.mounts[b]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,b)=>e.mountpoints.filter(v=>v.startsWith(c)||b&&c.startsWith(v)).map(v=>({relativeBase:c.length>v.length?c.slice(v.length):void 0,mountpoint:v,driver:e.mounts[v]})),n=(c,b)=>{if(e.watching){b=Pt(b);for(let v of e.watchListeners)v(c,b)}},s=async()=>{if(!e.watching){e.watching=!0;for(let c in e.mounts)e.unwatch[c]=await Fl(e.mounts[c],n,c)}},o=async()=>{if(e.watching){for(let c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},f=(c,b,v)=>{let S=new Map,I=M=>{let T=S.get(M.base);return T||(T={driver:M.driver,base:M.base,items:[]},S.set(M.base,T)),T};for(let M of c){let T=typeof M=="string",O=Pt(T?M:M.key),P=T?void 0:M.value,z=T||!M.options?b:{...b,...M.options},B=t(O);I(B).items.push({key:O,value:P,relativeKey:B.relativeKey,options:z})}return Promise.all([...S.values()].map(M=>v(M))).then(M=>M.flat())},u={hasItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.hasItem,v,b)},getItem(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return ot(S.getItem,v,b).then(I=>Bs(I))},getItems(c,b){return f(c,b,v=>v.driver.getItems?ot(v.driver.getItems,v.items.map(S=>({key:S.relativeKey,options:S.options})),b).then(S=>S.map(I=>({key:Ll(v.base,I.key),value:Bs(I.value)}))):Promise.all(v.items.map(S=>ot(v.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Bs(I)})))))},getItemRaw(c,b={}){c=Pt(c);let{relativeKey:v,driver:S}=t(c);return S.getItemRaw?ot(S.getItemRaw,v,b):ot(S.getItem,v,b).then(I=>Ol(I))},async setItem(c,b,v={}){if(b===void 0)return u.removeItem(c);c=Pt(c);let{relativeKey:S,driver:I}=t(c);I.setItem&&(await ot(I.setItem,S,ks(b),v),I.watch||n("update",c))},async setItems(c,b){await f(c,b,async v=>{if(v.driver.setItems)return ot(v.driver.setItems,v.items.map(S=>({key:S.relativeKey,value:ks(S.value),options:S.options})),b);v.driver.setItem&&await Promise.all(v.items.map(S=>ot(v.driver.setItem,S.relativeKey,ks(S.value),S.options)))})},async setItemRaw(c,b,v={}){if(b===void 0)return u.removeItem(c,v);c=Pt(c);let{relativeKey:S,driver:I}=t(c);if(I.setItemRaw)await ot(I.setItemRaw,S,b,v);else if(I.setItem)await ot(I.setItem,S,Cl(b),v);else return;I.watch||n("update",c)},async removeItem(c,b={}){typeof b=="boolean"&&(b={removeMeta:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c);S.removeItem&&(await ot(S.removeItem,v,b),(b.removeMeta||b.removeMata)&&await ot(S.removeItem,v+"$",b),S.watch||n("remove",c))},async getMeta(c,b={}){typeof b=="boolean"&&(b={nativeOnly:b}),c=Pt(c);let{relativeKey:v,driver:S}=t(c),I=Object.create(null);if(S.getMeta&&Object.assign(I,await ot(S.getMeta,v,b)),!b.nativeOnly){let M=await ot(S.getItem,v+"$",b).then(T=>Bs(T));M&&typeof M=="object"&&(typeof M.atime=="string"&&(M.atime=new Date(M.atime)),typeof M.mtime=="string"&&(M.mtime=new Date(M.mtime)),Object.assign(I,M))}return I},setMeta(c,b,v={}){return this.setItem(c+"$",b,v)},removeMeta(c,b={}){return this.removeItem(c+"$",b)},async getKeys(c,b={}){c=Ks(c);let v=i(c,!0),S=[],I=[];for(let M of v){let T=await ot(M.driver.getKeys,M.relativeBase,b);for(let O of T){let P=M.mountpoint+Pt(O);S.some(z=>P.startsWith(z))||I.push(P)}S=[M.mountpoint,...S.filter(O=>!O.startsWith(M.mountpoint))]}return c?I.filter(M=>M.startsWith(c)&&M[M.length-1]!=="$"):I.filter(M=>M[M.length-1]!=="$")},async clear(c,b={}){c=Ks(c),await Promise.all(i(c,!1).map(async v=>{if(v.driver.clear)return ot(v.driver.clear,v.relativeBase,b);if(v.driver.removeItem){let S=await v.driver.getKeys(v.relativeBase||"",b);return Promise.all(S.map(I=>v.driver.removeItem(I,b)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>ql(c)))},async watch(c){return await s(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(b=>b!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,b){if(c=Ks(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((v,S)=>S.length-v.length)),e.mounts[c]=b,e.watching&&Promise.resolve(Fl(b,n,c)).then(v=>{e.unwatch[c]=v}).catch(console.error),u},async unmount(c,b=!0){c=Ks(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&(e.unwatch[c](),delete e.unwatch[c]),b&&await ql(e.mounts[c]),e.mountpoints=e.mountpoints.filter(v=>v!==c),delete e.mounts[c])},getMount(c=""){c=Pt(c)+":";let b=t(c);return{driver:b.driver,base:b.base}},getMounts(c="",b={}){return c=Pt(c),i(c,b.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(c,b={})=>u.getKeys(c,b),get:(c,b={})=>u.getItem(c,b),set:(c,b,v={})=>u.setItem(c,b,v),has:(c,b={})=>u.hasItem(c,b),del:(c,b={})=>u.removeItem(c,b),remove:(c,b={})=>u.removeItem(c,b)};return u}function Fl(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ql(r){typeof r.dispose=="function"&&await ot(r.dispose)}function ln(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function _c(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=ln(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var wc;function js(){return wc||(wc=_c("keyval-store","keyval")),wc}function xc(r,e=js()){return e("readonly",t=>ln(t.get(r)))}function zl(r,e,t=js()){return t("readwrite",i=>(i.put(e,r),ln(i.transaction)))}function Bl(r,e=js()){return e("readwrite",t=>(t.delete(r),ln(t.transaction)))}function kl(r=js()){return r("readwrite",e=>(e.clear(),ln(e.transaction)))}function d2(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},ln(r.transaction)}function Kl(r=js()){return r("readonly",e=>{if(e.getAllKeys)return ln(e.getAllKeys());let t=[];return d2(e,i=>t.push(i.key)).then(()=>t)})}var l2=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),p2=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Fr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return p2(r)}catch{return r}}function Wt(r){return typeof r=="string"?r:l2(r)||""}var g2="idb-keyval",b2=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=_c(r.dbName,r.storeName)),{name:g2,options:r,async hasItem(n){return!(typeof await xc(t(n),i)>"u")},async getItem(n){return await xc(t(n),i)??null},setItem(n,s){return zl(t(n),s,i)},removeItem(n){return Bl(t(n),i)},getKeys(){return Kl(i)},clear(){return kl(i)}}},v2="WALLET_CONNECT_V2_INDEXED_DB",m2="keyvaluestorage",Sc=class{constructor(){this.indexedDb=Ul({driver:b2({dbName:v2,storeName:m2})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,Wt(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},Ec=typeof globalThis<"u"?globalThis:typeof window<"u"||typeof window<"u"?window:typeof self<"u"?self:{},oa={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Ec<"u"&&Ec.localStorage?oa.exports=Ec.localStorage:typeof window<"u"&&window.localStorage?oa.exports=window.localStorage:oa.exports=new e})();function y2(r){var e;return[r[0],Fr((e=r[1])!=null?e:"")]}var Ic=class{constructor(){this.localStorage=oa.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(y2)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Fr(t)}async setItem(e,t){this.localStorage.setItem(e,Wt(t))}async removeItem(e){this.localStorage.removeItem(e)}},w2="wc_storage_version",jl=1,_2=async(r,e,t)=>{let i=w2,n=await e.getItem(i);if(n&&n>=jl){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let f=s.shift();if(!f)continue;let u=f.toLowerCase();if(u.includes("wc@")||u.includes("walletconnect")||u.includes("wc_")||u.includes("wallet_connect")){let c=await r.getItem(f);await e.setItem(f,c),o.push(f)}}await e.setItem(i,jl),t(e),x2(r,o)},x2=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},aa=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new Ic;this.storage=e;try{let t=new Sc;_2(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var ai=qe(Rc()),Hs=qe(Rc());var L2={level:"info"},Gs="custom_context",Nc=1e3*1024,Tc=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},ha=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new Tc(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},ua=class{constructor(e,t=Nc){this.level=e??"error",this.levelValue=ai.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===ai.levels.values.error?console.error(e):t===ai.levels.values.warn?console.warn(e):t===ai.levels.values.debug?console.debug(e):t===ai.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Wt({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new ha(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(Wt({extraMetadata:e})),new Blob(t,{type:"application/json"})}},Dc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},Pc=class{constructor(e,t=Nc){this.baseChunkLogger=new ua(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},F2=Object.defineProperty,q2=Object.defineProperties,U2=Object.getOwnPropertyDescriptors,Yl=Object.getOwnPropertySymbols,z2=Object.prototype.hasOwnProperty,B2=Object.prototype.propertyIsEnumerable,Xl=(r,e,t)=>e in r?F2(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,da=(r,e)=>{for(var t in e||(e={}))z2.call(e,t)&&Xl(r,t,e[t]);if(Yl)for(var t of Yl(e))B2.call(e,t)&&Xl(r,t,e[t]);return r},la=(r,e)=>q2(r,U2(e));function Ws(r){return la(da({},r),{level:r?.level||L2.level})}function k2(r,e=Gs){return r[e]||""}function K2(r,e,t=Gs){return r[t]=e,r}function yt(r,e=Gs){let t="";return typeof r.bindings>"u"?t=k2(r,e):t=r.bindings().context||"",t}function j2(r,e,t=Gs){let i=yt(r,t);return i.trim()?`${i}/${e}`:e}function lt(r,e,t=Gs){let i=j2(r,e,t),n=r.child({context:i});return K2(n,i,t)}function V2(r){var e,t;let i=new Dc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace",browser:la(da({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function $2(r){var e;let t=new Pc((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,ai.default)(la(da({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function Zl(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?V2(r):$2(r)}var Ql=qe(un()),pa=class extends sr{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var ga=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},ba=class{constructor(e,t){this.logger=e,this.core=t}},va=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}},ma=class extends sr{constructor(e){super()}},ya=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var wa=class extends sr{constructor(e,t){super(),this.relayer=e,this.logger=t}};var _a=class extends sr{constructor(e,t){super(),this.core=e,this.logger=t}};var xa=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Ea=class{constructor(e,t){this.projectId=e,this.logger=t}},Sa=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var Ia=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Ma=class{constructor(e){this.client=e}};var re=qe(jn());var so=qe(T0()),op=qe(Js()),ap=qe(jn());var D0="EdDSA",P0="JWT",Zs=".",Qs="base64url",Xc="utf8",Zc="utf8",N0=":",C0="did",O0="key",Qc="base58btc",L0="z",F0="K36";function eo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function vn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=eo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var nh={};Dt(nh,{identity:()=>$3});function B3(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var k3=B3,K3=k3,q0=K3;var FI=new Uint8Array(0);var U0=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var z0=r=>new TextEncoder().encode(r),B0=r=>new TextDecoder().decode(r);var eh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},th=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return K0(this,e)}},rh=class{constructor(e){this.decoders=e}or(e){return K0(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},K0=(r,e)=>new rh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),ih=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new eh(e,t,i),this.decoder=new th(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Yn=({name:r,prefix:e,encode:t,decode:i})=>new ih(r,e,t,i),Ti=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=q0(t,e);return Yn({prefix:r,name:e,encode:i,decode:s=>ci(n(s))})},j3=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},V3=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Yn({prefix:e,name:r,encode(n){return V3(n,i,t)},decode(n){return j3(n,i,t,r)}});var $3=Yn({prefix:"\0",name:"identity",encode:r=>B0(r),decode:r=>z0(r)});var sh={};Dt(sh,{base2:()=>H3});var H3=Xe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var oh={};Dt(oh,{base8:()=>G3});var G3=Xe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ah={};Dt(ah,{base10:()=>W3});var W3=Ti({prefix:"9",name:"base10",alphabet:"0123456789"});var fh={};Dt(fh,{base16:()=>J3,base16upper:()=>Y3});var J3=Xe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Y3=Xe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ch={};Dt(ch,{base32:()=>Xn,base32hex:()=>e6,base32hexpad:()=>r6,base32hexpadupper:()=>i6,base32hexupper:()=>t6,base32pad:()=>Z3,base32padupper:()=>Q3,base32upper:()=>X3,base32z:()=>n6});var Xn=Xe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),X3=Xe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Z3=Xe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Q3=Xe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),e6=Xe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),t6=Xe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),r6=Xe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),i6=Xe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),n6=Xe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var hh={};Dt(hh,{base36:()=>s6,base36upper:()=>o6});var s6=Ti({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),o6=Ti({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var uh={};Dt(uh,{base58btc:()=>Ur,base58flickr:()=>a6});var Ur=Ti({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),a6=Ti({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var dh={};Dt(dh,{base64:()=>f6,base64pad:()=>c6,base64url:()=>h6,base64urlpad:()=>u6});var f6=Xe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),c6=Xe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h6=Xe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),u6=Xe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var lh={};Dt(lh,{base256emoji:()=>b6});var j0=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),d6=j0.reduce((r,e,t)=>(r[t]=e,r),[]),l6=j0.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function p6(r){return r.reduce((e,t)=>(e+=d6[t],e),"")}function g6(r){let e=[];for(let t of r){let i=l6[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var b6=Yn({prefix:"\u{1F680}",name:"base256emoji",encode:p6,decode:g6});var vh={};Dt(vh,{sha256:()=>L6,sha512:()=>F6});var v6=H0,V0=128,m6=127,y6=~m6,w6=Math.pow(2,31);function H0(r,e,t){e=e||[],t=t||0;for(var i=t;r>=w6;)e[t++]=r&255|V0,r/=128;for(;r&y6;)e[t++]=r&255|V0,r>>>=7;return e[t]=r|0,H0.bytes=t-i+1,e}var _6=ph,x6=128,$0=127;function ph(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw ph.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&$0)<=x6);return ph.bytes=s-i,t}var E6=Math.pow(2,7),S6=Math.pow(2,14),I6=Math.pow(2,21),M6=Math.pow(2,28),A6=Math.pow(2,35),R6=Math.pow(2,42),T6=Math.pow(2,49),D6=Math.pow(2,56),P6=Math.pow(2,63),N6=function(r){return r[to.decode(r,e),to.decode.bytes],Zn=(r,e,t=0)=>(to.encode(r,e,t),e),Qn=r=>to.encodingLength(r);var mn=(r,e)=>{let t=e.byteLength,i=Qn(r),n=i+Qn(t),s=new Uint8Array(n+t);return Zn(r,s,0),Zn(t,s,i),s.set(e,n),new es(r,t,e,s)},G0=r=>{let e=ci(r),[t,i]=ro(e),[n,s]=ro(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new es(t,n,o,e)},W0=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&U0(r.bytes,e.bytes),es=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var bh=({name:r,code:e,encode:t})=>new gh(r,e,t),gh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?mn(this.code,t):t.then(i=>mn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var Y0=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),L6=bh({name:"sha2-256",code:18,encode:Y0("SHA-256")}),F6=bh({name:"sha2-512",code:19,encode:Y0("SHA-512")});var mh={};Dt(mh,{identity:()=>z6});var X0=0,q6="identity",Z0=ci,U6=r=>mn(X0,Z0(r)),z6={code:X0,name:q6,encode:Z0,digest:U6};var iM=new TextEncoder,nM=new TextDecoder;var La=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Oa,byteLength:Oa,code:Ca,version:Ca,multihash:Ca,bytes:Ca,_baseCache:Oa,asCID:Oa})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==no)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==$6)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=mn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&W0(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return j6(t,n,e||Ur.encoder);default:return V6(t,n,e||Xn.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return G6(/^0\.0/,W6),!!(e&&(e[ep]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||Q0(t,i,n.bytes))}else if(e!=null&&e[ep]===!0){let{version:t,multihash:i,code:n}=e,s=G0(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==no)throw new Error(`Version 0 CID must use dag-pb (code: ${no}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=Q0(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,no,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=ci(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new es(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[v,S]=ro(e.subarray(t));return t+=S,v},n=i(),s=no;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,f=i(),u=i(),c=t+u,b=c-o;return{version:n,codec:s,multihashCode:f,digestSize:u,multihashSize:b,size:c}}static parse(e,t){let[i,n]=K6(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},K6=(r,e)=>{switch(r[0]){case"Q":{let t=e||Ur;return[Ur.prefix,t.decode(`${Ur.prefix}${r}`)]}case Ur.prefix:{let t=e||Ur;return[Ur.prefix,t.decode(r)]}case Xn.prefix:{let t=e||Xn;return[Xn.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},j6=(r,e,t)=>{let{prefix:i}=t;if(i!==Ur.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},V6=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},no=112,$6=18,Q0=(r,e,t)=>{let i=Qn(r),n=i+Qn(e),s=new Uint8Array(n+t.byteLength);return Zn(r,s,0),Zn(e,s,i),s.set(t,n),s},ep=Symbol.for("@ipld/js-cid/CID"),Ca={writable:!1,configurable:!1,enumerable:!0},Oa={writable:!1,enumerable:!1,configurable:!1},H6="0.0.0-dev",G6=(r,e)=>{if(r.test(H6))console.warn(e);else throw new Error(e)},W6=`CID.isCID(v) is deprecated and will be removed in the next major release. +Following code pattern: + +if (CID.isCID(value)) { + doSomethingWithCID(value) +} + +Is replaced with: + +const cid = CID.asCID(value) +if (cid) { + // Make sure to use cid instead of value + doSomethingWithCID(cid) +} +`;var yh={...nh,...sh,...oh,...ah,...fh,...ch,...hh,...uh,...dh,...lh},dM={...vh,...mh};function rp(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var tp=rp("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),wh=rp("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=eo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new nw:typeof navigator<"u"?dp(navigator.userAgent):hw()}function fw(r){return r!==""&&aw.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function dp(r){var e=fw(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new iw;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var Bp=Nw(),Ih;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(Ih||(Ih={}));var or;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(or||(or={}));var kp="0123456789abcdef",at=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();Ka[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(zp>Ka[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(Up)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(u=>{let c=i[u];try{if(c instanceof Uint8Array){let b="";for(let v=0;v>4],b+=kp[c[v]&15];n.push(u+"=Uint8Array(0x"+b+")")}else n.push(u+"="+JSON.stringify(c))}catch{n.push(u+"="+JSON.stringify(i[u].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case or.NUMERIC_FAULT:{o="NUMERIC_FAULT";let u=e;switch(u){case"overflow":case"underflow":case"division-by-zero":o+="-"+u;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case or.CALL_EXCEPTION:case or.INSUFFICIENT_FUNDS:case or.MISSING_NEW:case or.NONCE_EXPIRED:case or.REPLACEMENT_UNDERPRICED:case or.TRANSACTION_REPLACED:case or.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let f=new Error(e);return f.reason=s,f.code=t,Object.keys(i).forEach(function(u){f[u]=i[u]}),f}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),Bp&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:Bp})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return Sh||(Sh=new r(Fp)),Sh}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),qp){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}Up=!!e,qp=!!t}static setLogLevel(e){let t=Ka[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}zp=t}static from(e){return new r(e)}};at.errors=or;at.levels=Ih;var Kp="bytes/5.7.0";var nt=new at(Kp);function Vp(r){return!!r.toHexString}function is(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return is(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function $p(r){return ar(r)&&!(r.length%2)||Ah(r)}function jp(r){return typeof r=="number"&&r==r&&r%1===0}function Ah(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!jp(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function We(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),is(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r)&&(r=r.toHexString()),ar(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":nt.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nWe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),is(i)}function Cw(r,e){r=We(r),r.length>e&&nt.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),is(t)}function ar(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var Mh="0123456789abcdef";function _t(r,e){if(e||(e={}),typeof r=="number"){nt.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=Mh[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),Vp(r))return r.toHexString();if(ar(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":nt.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(Ah(r)){let t="0x";for(let i=0;i>4]+Mh[n&15]}return t}return nt.throwArgumentError("invalid hexlify value","value",r)}function ja(r){if(typeof r!="string")r=_t(r);else if(!ar(r)||r.length%2)return null;return(r.length-2)/2}function Va(r,e,t){return typeof r!="string"?r=_t(r):(!ar(r)||r.length%2)&&nt.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Di(r,e){for(typeof r!="string"?r=_t(r):ar(r)||nt.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&nt.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function $a(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if($p(r)){let t=We(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64))):t.length===65?(e.r=_t(t.slice(0,32)),e.s=_t(t.slice(32,64)),e.v=t[64]):nt.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:nt.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=_t(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=Cw(We(e._vs),32);e._vs=_t(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&nt.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=_t(n);e.s==null?e.s=o:e.s!==o&&nt.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?nt.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&nt.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!ar(e.r)?nt.throwArgumentError("signature missing or invalid r","signature",r):e.r=Di(e.r,32),e.s==null||!ar(e.s)?nt.throwArgumentError("signature missing or invalid s","signature",r):e.s=Di(e.s,32);let t=We(e.s);t[0]>=128&&nt.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=_t(t);e._vs&&(ar(e._vs)||nt.throwArgumentError("signature invalid _vs","signature",r),e._vs=Di(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&nt.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function ns(r){return"0x"+Hp.default.keccak_256(We(r))}var Jp=qe(Ph());var Wp="bignumber/5.7.0";var Ow=Jp.default.BN,sA=new at(Wp);function Nh(r){return new Ow(r,36).toString(16)}var Yp="strings/5.7.0";var Xp=new at(Yp),oo;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(oo||(oo={}));var wn;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})(wn||(wn={}));function Fw(r,e,t,i,n){return Xp.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function Zp(r,e,t,i,n){if(r===wn.BAD_PREFIX||r===wn.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===wn.OVERRUN?t.length-e-1:0}function qw(r,e,t,i,n){return r===wn.OVERLONG?(i.push(n),0):(i.push(65533),Zp(r,e,t,i,n))}var Uw=Object.freeze({error:Fw,ignore:Zp,replace:qw});function ao(r,e=oo.current){e!=oo.current&&(Xp.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return We(t)}var Qp=`Ethereum Signed Message: +`;function Ha(r){return typeof r=="string"&&(r=ao(r)),ns(Rh([ao(Qp),ao(String(r.length)),r]))}var e1="address/5.7.0";var fo=new at(e1);function t1(r){ar(r,20)||fo.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=We(ns(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var Bw=9007199254740991;function kw(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var Ch={};for(let r=0;r<10;r++)Ch[String(r)]=String(r);for(let r=0;r<26;r++)Ch[String.fromCharCode(65+r)]=String(10+r);var r1=Math.floor(kw(Bw));function Kw(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>Ch[i]).join("");for(;e.length>=r1;){let i=e.substring(0,r1);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function i1(r){let e=null;if(typeof r!="string"&&fo.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=t1(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&fo.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==Kw(r)&&fo.throwArgumentError("bad icap checksum","address",r),e=Nh(r.substring(4));e.length<40;)e="0"+e;e=t1("0x"+e)}else fo.throwArgumentError("invalid address","address",r);return e}var n1="properties/5.7.0";var OA=new at(n1);function ss(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Ce=qe(Ph()),$r=qe(lo());function ds(r,e,t){return t={path:e,exports:{},require:function(i,n){return u8(i,n??t.path)}},r(t,t.exports),t.exports}function u8(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Hh=k1;function k1(r,e){if(!r)throw new Error(e||"Assertion failed")}k1.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var ur=ds(function(r,e){"use strict";var t=e;function i(o,f){if(Array.isArray(o))return o.slice();if(!o)return[];var u=[];if(typeof o!="string"){for(var c=0;c>8,S=b&255;v?u.push(v,S):u.push(S)}return u}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var f="",u=0;u(S>>1)-1?T=(S>>1)-O:T=O,I.isubn(T)):T=0,v[M]=T,I.iushrn(1)}return v}t.getNAF=i;function n(u,c){var b=[[],[]];u=u.clone(),c=c.clone();for(var v=0,S=0,I;u.cmpn(-v)>0||c.cmpn(-S)>0;){var M=u.andln(3)+v&3,T=c.andln(3)+S&3;M===3&&(M=-1),T===3&&(T=-1);var O;M&1?(I=u.andln(7)+v&7,(I===3||I===5)&&T===2?O=-M:O=M):O=0,b[0].push(O);var P;T&1?(I=c.andln(7)+S&7,(I===3||I===5)&&M===2?P=-T:P=T):P=0,b[1].push(P),2*v===O+1&&(v=1-v),2*S===P+1&&(S=1-S),u.iushrn(1),c.iushrn(1)}return b}t.getJSF=n;function s(u,c,b){var v="_"+c;u.prototype[c]=function(){return this[v]!==void 0?this[v]:this[v]=b.call(this)}}t.cachedProperty=s;function o(u){return typeof u=="string"?t.toArray(u,"hex"):u}t.parseBytes=o;function f(u){return new Ce.default(u,"hex","le")}t.intFromLE=f}),Xa=zt.getNAF,d8=zt.getJSF,Za=zt.assert;function Oi(r,e){this.type=r,this.p=new Ce.default(e.p,16),this.red=e.prime?Ce.default.red(e.prime):Ce.default.mont(this.p),this.zero=new Ce.default(0).toRed(this.red),this.one=new Ce.default(1).toRed(this.red),this.two=new Ce.default(2).toRed(this.red),this.n=e.n&&new Ce.default(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var xn=Oi;Oi.prototype.point=function(){throw new Error("Not implemented")};Oi.prototype.validate=function(){throw new Error("Not implemented")};Oi.prototype._fixedNafMul=function(e,t){Za(e.precomputed);var i=e._getDoubles(),n=Xa(t,1,this._bitLength),s=(1<=f;c--)u=(u<<1)+n[c];o.push(u)}for(var b=this.jpoint(null,null,null),v=this.jpoint(null,null,null),S=s;S>0;S--){for(f=0;f=0;u--){for(var c=0;u>=0&&o[u]===0;u--)c++;if(u>=0&&c++,f=f.dblp(c),u<0)break;var b=o[u];Za(b!==0),e.type==="affine"?b>0?f=f.mixedAdd(s[b-1>>1]):f=f.mixedAdd(s[-b-1>>1].neg()):b>0?f=f.add(s[b-1>>1]):f=f.add(s[-b-1>>1].neg())}return e.type==="affine"?f.toP():f};Oi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,f=this._wnafT2,u=this._wnafT3,c=0,b,v,S;for(b=0;b=1;b-=2){var M=b-1,T=b;if(o[M]!==1||o[T]!==1){u[M]=Xa(i[M],o[M],this._bitLength),u[T]=Xa(i[T],o[T],this._bitLength),c=Math.max(u[M].length,c),c=Math.max(u[T].length,c);continue}var O=[t[M],null,null,t[T]];t[M].y.cmp(t[T].y)===0?(O[1]=t[M].add(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg())):t[M].y.cmp(t[T].y.redNeg())===0?(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].add(t[T].neg())):(O[1]=t[M].toJ().mixedAdd(t[T]),O[2]=t[M].toJ().mixedAdd(t[T].neg()));var P=[-3,-1,-5,-7,0,7,5,1,3],z=d8(i[M],i[T]);for(c=Math.max(z[0].length,c),u[M]=new Array(c),u[T]=new Array(c),v=0;v=0;b--){for(var L=0;b>=0;){var C=!0;for(v=0;v=0&&L++,j=j.dblp(L),b<0)break;for(v=0;v0?S=f[v][W-1>>1]:W<0&&(S=f[v][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(b=0;b=Math.ceil((e.bitLength()+1)/t.step):!1};Xt.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=c,M=b),v.negative&&(v=v.neg(),S=S.neg()),I.negative&&(I=I.neg(),M=M.neg()),[{a:v,b:S},{a:I,b:M}]};Zt.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),f=s.mul(i.a),u=o.mul(n.a),c=s.mul(i.b),b=o.mul(n.b),v=e.sub(f).sub(u),S=c.add(b).neg();return{k1:v,k2:S}};Zt.prototype.pointFromX=function(e,t){e=new Ce.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};Zt.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};Zt.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};ft.prototype.isInfinity=function(){return this.inf};ft.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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};ft.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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),o=s.redSqr().redISub(this.x.redAdd(this.x)),f=s.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,f)};ft.prototype.getX=function(){return this.x.fromRed()};ft.prototype.getY=function(){return this.y.fromRed()};ft.prototype.mul=function(e){return e=new Ce.default(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)};ft.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};ft.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};ft.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)};ft.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};ft.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 gt(r,e,t,i){xn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Ce.default(0)):(this.x=new Ce.default(e,16),this.y=new Ce.default(t,16),this.z=new Ce.default(i,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}Gh(gt,xn.BasePoint);Zt.prototype.jpoint=function(e,t,i){return new gt(this,e,t,i)};gt.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};gt.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};gt.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),f=e.y.redMul(i.redMul(this.z)),u=n.redSub(s),c=o.redSub(f);if(u.cmpn(0)===0)return c.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var b=u.redSqr(),v=b.redMul(u),S=n.redMul(b),I=c.redSqr().redIAdd(v).redISub(S).redISub(S),M=c.redMul(S.redISub(I)).redISub(o.redMul(v)),T=this.z.redMul(e.z).redMul(u);return this.curve.jpoint(I,M,T)};gt.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),f=i.redSub(n),u=s.redSub(o);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var c=f.redSqr(),b=c.redMul(f),v=i.redMul(c),S=u.redSqr().redIAdd(b).redISub(v).redISub(v),I=u.redMul(v.redISub(S)).redISub(s.redMul(b)),M=this.z.redMul(f);return this.curve.jpoint(S,I,M)};gt.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};gt.prototype.inspect=function(){return this.isInfinity()?"":""};gt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var Ja=ds(function(r,e){"use strict";var t=e;t.base=xn,t.short=p8,t.mont=null,t.edwards=null}),Ya=ds(function(r,e){"use strict";var t=e,i=zt.assert;function n(f){f.type==="short"?this.curve=new Ja.short(f):f.type==="edwards"?this.curve=new Ja.edwards(f):this.curve=new Ja.mont(f),this.g=this.curve.g,this.n=this.curve.n,this.hash=f.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(f,u){Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var c=new n(u);return Object.defineProperty(t,f,{configurable:!0,enumerable:!0,value:c}),c}})}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:$r.default.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:$r.default.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:$r.default.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:$r.default.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:$r.default.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:$r.default.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:$r.default.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:$r.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Ci(r){if(!(this instanceof Ci))return new Ci(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=ur.toArray(r.entropy,r.entropyEnc||"hex"),t=ur.toArray(r.nonce,r.nonceEnc||"hex"),i=ur.toArray(r.pers,r.persEnc||"hex");Hh(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var K1=Ci;Ci.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);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(i||[])),this._reseed=1};Ci.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=ur.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var g8=zt.assert;function Qa(r,e){if(r instanceof Qa)return r;this._importDER(r,e)||(g8(r.r&&r.s,"Signature without r or s"),this.r=new Ce.default(r.r,16),this.s=new Ce.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var ef=Qa;function b8(){this.place=0}function jh(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function B1(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Qa.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=B1(t),i=B1(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Vh(n,t.length),n=n.concat(t),n.push(2),Vh(n,i.length);var s=n.concat(i),o=[48];return Vh(o,s.length),o=o.concat(s),zt.encode(o,e)};var v8=function(){throw new Error("unsupported")},j1=zt.assert;function Yt(r){if(!(this instanceof Yt))return new Yt(r);typeof r=="string"&&(j1(Object.prototype.hasOwnProperty.call(Ya,r),"Unknown curve "+r),r=Ya[r]),r instanceof Ya.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var m8=Yt;Yt.prototype.keyPair=function(e){return new Wh(this,e)};Yt.prototype.keyFromPrivate=function(e,t){return Wh.fromPrivate(this,e,t)};Yt.prototype.keyFromPublic=function(e,t){return Wh.fromPublic(this,e,t)};Yt.prototype.genKeyPair=function(e){e||(e={});for(var t=new K1({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||v8(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Ce.default(2));;){var s=new Ce.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};Yt.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};Yt.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Ce.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),f=e.toArray("be",s),u=new K1({hash:this.hash,entropy:o,nonce:f,pers:n.pers,persEnc:n.persEnc||"utf8"}),c=this.n.sub(new Ce.default(1)),b=0;;b++){var v=n.k?n.k(b):new Ce.default(u.generate(this.n.byteLength()));if(v=this._truncateToN(v,!0),!(v.cmpn(1)<=0||v.cmp(c)>=0)){var S=this.g.mul(v);if(!S.isInfinity()){var I=S.getX(),M=I.umod(this.n);if(M.cmpn(0)!==0){var T=v.invm(this.n).mul(M.mul(t.getPrivate()).iadd(e));if(T=T.umod(this.n),T.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(M)!==0?2:0);return n.canonical&&T.cmp(this.nh)>0&&(T=this.n.sub(T),O^=1),new ef({r:M,s:T,recoveryParam:O})}}}}}};Yt.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Ce.default(e,16)),i=this.keyFromPublic(i,n),t=new ef(t,"hex");var s=t.r,o=t.s;if(s.cmpn(1)<0||s.cmp(this.n)>=0||o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var f=o.invm(this.n),u=f.mul(e).umod(this.n),c=f.mul(s).umod(this.n),b;return this.curve._maxwellTrick?(b=this.g.jmulAdd(u,i.getPublic(),c),b.isInfinity()?!1:b.eqXToP(s)):(b=this.g.mulAdd(u,i.getPublic(),c),b.isInfinity()?!1:b.getX().umod(this.n).cmp(s)===0)};Yt.prototype.recoverPubKey=function(r,e,t,i){j1((3&t)===t,"The recovery param is more than two bits"),e=new ef(e,i);var n=this.n,s=new Ce.default(r),o=e.r,f=e.s,u=t&1,c=t>>1;if(o.cmp(this.curve.p.umod(this.curve.n))>=0&&c)throw new Error("Unable to find sencond key candinate");c?o=this.curve.pointFromX(o.add(this.curve.n),u):o=this.curve.pointFromX(o,u);var b=e.r.invm(n),v=n.sub(s).mul(b).umod(n),S=f.mul(b).umod(n);return this.g.mulAdd(v,o,S)};Yt.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new ef(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var y8=ds(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=zt,t.rand=function(){throw new Error("unsupported")},t.curve=Ja,t.curves=Ya,t.ec=m8,t.eddsa=null}),V1=y8.ec;var $1="signing-key/5.7.0";var Yh=new at($1),Jh=null;function Hr(){return Jh||(Jh=new V1("secp256k1")),Jh}var Xh=class{constructor(e){ss(this,"curve","secp256k1"),ss(this,"privateKey",_t(e)),ja(this.privateKey)!==32&&Yh.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=Hr().keyFromPrivate(We(this.privateKey));ss(this,"publicKey","0x"+t.getPublic(!1,"hex")),ss(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),ss(this,"_isSigningKey",!0)}_addPoint(e){let t=Hr().keyFromPublic(We(this.publicKey)),i=Hr().keyFromPublic(We(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=We(e);i.length!==32&&Yh.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return $a({recoveryParam:n.recoveryParam,r:Di("0x"+n.r.toString(16),32),s:Di("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=Hr().keyFromPrivate(We(this.privateKey)),i=Hr().keyFromPublic(We(Zh(e)));return Di("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function H1(r,e){let t=$a(e),i={r:We(t.r),s:We(t.s)};return"0x"+Hr().recoverPubKey(We(r),i,t.recoveryParam).encode("hex",!1)}function Zh(r,e){let t=We(r);if(t.length===32){let i=new Xh(t);return e?"0x"+Hr().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?_t(t):"0x"+Hr().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+Hr().keyFromPublic(t).getPublic(!0,"hex"):_t(t)}return Yh.throwArgumentError("invalid public or private key","key","[REDACTED]")}var G1="transactions/5.7.0";var pR=new at(G1),W1;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(W1||(W1={}));function w8(r){let e=Zh(r);return i1(Va(ns(Va(e,1)),12))}function J1(r,e){return w8(H1(We(r),e))}var Eu=qe(ig()),xb=qe(cg()),Eo=qe(Js()),ws=qe(ug()),Sf=qe(gg());var Eb=qe(fb());var cb={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var E4=":";function So(r){let[e,t]=r.split(E4);return{namespace:e,reference:t}}function Sb(r,e){return r.includes(":")?[r]:e.chains||[]}var S4=Object.defineProperty,hb=Object.getOwnPropertySymbols,I4=Object.prototype.hasOwnProperty,M4=Object.prototype.propertyIsEnumerable,ub=(r,e,t)=>e in r?S4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,db=(r,e)=>{for(var t in e||(e={}))I4.call(e,t)&&ub(r,t,e[t]);if(hb)for(var t of hb(e))M4.call(e,t)&&ub(r,t,e[t]);return r},A4="ReactNative",Ft={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var R4="js";function Io(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Tn(){return!(0,wi.getDocument)()&&!!(0,wi.getNavigator)()&&navigator.product===A4}function _s(){return!Io()&&!!(0,wi.getNavigator)()&&!!(0,wi.getDocument)()}function Mo(){return Tn()?Ft.reactNative:Io()?Ft.node:_s()?Ft.browser:Ft.unknown}function Ib(){var r;try{return Tn()&&typeof window<"u"&&typeof window?.Application<"u"?(r=window.Application)==null?void 0:r.applicationId:void 0}catch{return}}function T4(r,e){let t=ys.parse(r);return t=db(db({},t),e),r=ys.stringify(t),r}function xs(){return(0,_b.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function D4(){if(Mo()===Ft.reactNative&&typeof window<"u"&&typeof window?.Platform<"u"){let{OS:t,Version:i}=window.Platform;return[t,i].join("-")}let r=lp();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function P4(){var r;let e=Mo();return e===Ft.browser?[e,((r=(0,wi.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function Su(r,e,t){let i=D4(),n=P4();return[[r,e].join("-"),[R4,t].join("-"),i,n].join("/")}function Mb({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:f}){let u=t.split("?"),c=Su(r,e,i),b={auth:n,ua:c,projectId:s,useOnCloseEvent:o||void 0,origin:f||void 0},v=T4(u[1]||"",b);return u[0]+"?"+v}function An(r,e){return r.filter(t=>e.includes(t)).length===r.length}function Iu(r){return Object.fromEntries(r.entries())}function Mu(r){return new Map(Object.entries(r))}function _i(r=yi.FIVE_MINUTES,e){let t=(0,yi.toMiliseconds)(r||yi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,f)=>{s=setTimeout(()=>{f(new Error(e))},t),i=o,n=f})}}function Dn(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Ab(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Rb(r){return Ab("topic",r)}function Tb(r){return Ab("id",r)}function If(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function st(r,e){return(0,yi.fromMiliseconds)((e||Date.now())+(0,yi.toMiliseconds)(r))}function Xr(r){return Date.now()>=(0,yi.toMiliseconds)(r)}function Oe(r,e){return`${r}${e?`:${e}`:""}`}function N4(r=[],e=[]){return[...new Set([...r,...e])]}async function Db({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=C4(s,r,e),f=Mo();if(f===Ft.browser){if(!((i=(0,wi.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,O4()?"_blank":"_self","noreferrer noopener")}else f===Ft.reactNative&&typeof window?.Linking<"u"&&await window.Linking.openURL(o)}catch(n){console.error(n)}}function C4(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${L4(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Pb(r,e){let t="";try{if(_s()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function Au(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ru(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function Ao(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function O4(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function L4(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Nb(r){return Buffer.from(r,"base64").toString("utf-8")}var F4="https://rpc.walletconnect.org/v1";async function q4(r,e,t,i,n,s){switch(t.t){case"eip191":return U4(r,e,t.s);case"eip1271":return await z4(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function U4(r,e,t){return J1(Ha(e),t).toLowerCase()===r.toLowerCase()}async function z4(r,e,t,i,n,s){let o=So(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let f="0x1626ba7e",u="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",b=t.substring(2),v=Ha(e).substring(2),S=f+v+u+c+b,I=await fetch(`${s||F4}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:B4(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:M}=await I.json();return M?M.slice(0,f.length).toLowerCase()===f.toLowerCase():!1}catch(f){return console.error("isValidEip1271Signature: ",f),!1}}function B4(){return Date.now()+Math.floor(Math.random()*1e3)}var k4=Object.defineProperty,K4=Object.defineProperties,j4=Object.getOwnPropertyDescriptors,lb=Object.getOwnPropertySymbols,V4=Object.prototype.hasOwnProperty,$4=Object.prototype.propertyIsEnumerable,pb=(r,e,t)=>e in r?k4(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,H4=(r,e)=>{for(var t in e||(e={}))V4.call(e,t)&&pb(r,t,e[t]);if(lb)for(var t of lb(e))$4.call(e,t)&&pb(r,t,e[t]);return r},G4=(r,e)=>K4(r,j4(e)),W4="did:pkh:",Tu=r=>r?.split(":"),J4=r=>{let e=r&&Tu(r);if(e)return r.includes(W4)?e[3]:e[1]},Mf=r=>{let e=r&&Tu(r);if(e)return e[2]+":"+e[3]},Ro=r=>{let e=r&&Tu(r);if(e)return e.pop()};async function Du(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=Pu(n,n.iss),o=Ro(n.iss);return await q4(o,s,i,Mf(n.iss),t)}var Pu=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ro(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,f=`Chain ID: ${J4(e)}`,u=`Nonce: ${r.nonce}`,c=`Issued At: ${r.iat}`,b=r.exp?`Expiration Time: ${r.exp}`:void 0,v=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(T=>` +- ${T}`).join("")}`:void 0,M=To(r.resources);if(M){let T=xo(M);n=r_(n,T)}return[t,i,"",n,"",s,o,f,u,c,b,v,S,I].filter(T=>T!=null).join(` +`)};function Y4(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function X4(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function Rn(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function Z4(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:Q4(e,t,i)}}}function Q4(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function Cb(r){return Rn(r),`urn:recap:${Y4(r).replace(/=/g,"")}`}function xo(r){let e=X4(r.replace("urn:recap:",""));return Rn(e),e}function Ob(r,e,t){let i=Z4(r,e,t);return Cb(i)}function e_(r){return r&&r.includes("urn:recap:")}function Lb(r,e){let t=xo(r),i=xo(e),n=t_(t,i);return Cb(n)}function t_(r,e){Rn(r),Rn(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((f,u)=>f.localeCompare(u)).forEach(f=>{var u,c;i.att[n]=G4(H4({},i.att[n]),{[f]:((u=r.att[n])==null?void 0:u[f])||((c=e.att[n])==null?void 0:c[f])})})}),i}function r_(r="",e){Rn(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(f=>{let u=Object.keys(e.att[f]).map(v=>({ability:v.split("/")[0],action:v.split("/")[1]}));u.sort((v,S)=>v.action.localeCompare(S.action));let c={};u.forEach(v=>{c[v.ability]||(c[v.ability]=[]),c[v.ability].push(v.action)});let b=Object.keys(c).map(v=>(n++,`(${n}) '${v}': '${c[v].join("', '")}' for '${f}'.`));i.push(b.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function Nu(r){var e;let t=xo(r);Rn(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function Cu(r){let e=xo(r);Rn(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function To(r){if(!r)return;let e=r?.[r.length-1];return e_(e)?e:void 0}var Fb="base10",It="base16",Zr="base64pad",Es="base64url",Do="utf8",qb=0,lr=1,Ss=2,i_=0,gb=1,_o=12,Ou=32;function Ub(){let r=Sf.generateKeyPair();return{privateKey:Ze(r.secretKey,It),publicKey:Ze(r.publicKey,It)}}function Af(){let r=(0,Eo.randomBytes)(Ou);return Ze(r,It)}function zb(r,e){let t=Sf.sharedKey(rt(r,It),rt(e,It),!0),i=new xb.HKDF(ws.SHA256,t).expand(Ou);return Ze(i,It)}function Is(r){let e=(0,ws.hash)(rt(r,It));return Ze(e,It)}function pr(r){let e=(0,ws.hash)(rt(r,Do));return Ze(e,It)}function Bb(r){return rt(`${r}`,Fb)}function ki(r){return Number(Ze(r,Fb))}function kb(r){let e=Bb(typeof r.type<"u"?r.type:qb);if(ki(e)===lr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?rt(r.senderPublicKey,It):void 0,i=typeof r.iv<"u"?rt(r.iv,It):(0,Eo.randomBytes)(_o),n=new Eu.ChaCha20Poly1305(rt(r.symKey,It)).seal(i,rt(r.message,Do));return $b({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function Kb(r,e){let t=Bb(Ss),i=(0,Eo.randomBytes)(_o),n=rt(r,Do);return $b({type:t,sealed:n,iv:i,encoding:e})}function jb(r){let e=new Eu.ChaCha20Poly1305(rt(r.symKey,It)),{sealed:t,iv:i}=Ms({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return Ze(n,Do)}function Vb(r,e){let{sealed:t}=Ms({encoded:r,encoding:e});return Ze(t,Do)}function $b(r){let{encoding:e=Zr}=r;if(ki(r.type)===Ss)return Ze(vn([r.type,r.sealed]),e);if(ki(r.type)===lr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Ze(vn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return Ze(vn([r.type,r.iv,r.sealed]),e)}function Ms(r){let{encoded:e,encoding:t=Zr}=r,i=rt(e,t),n=i.slice(i_,gb),s=gb;if(ki(n)===lr){let c=s+Ou,b=c+_o,v=i.slice(s,c),S=i.slice(c,b),I=i.slice(b);return{type:n,sealed:I,iv:S,senderPublicKey:v}}if(ki(n)===Ss){let c=i.slice(s),b=(0,Eo.randomBytes)(_o);return{type:n,sealed:c,iv:b}}let o=s+_o,f=i.slice(s,o),u=i.slice(o);return{type:n,sealed:u,iv:f}}function Hb(r,e){let t=Ms({encoded:r,encoding:e?.encoding});return Lu({type:ki(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?Ze(t.senderPublicKey,It):void 0,receiverPublicKey:e?.receiverPublicKey})}function Lu(r){let e=r?.type||qb;if(e===lr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function Fu(r){return r.type===lr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function qu(r){return r.type===Ss}function n_(r){return new Eb.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function s_(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function o_(r){return Buffer.from(s_(r),"base64")}function Gb(r,e){let[t,i,n]=r.split("."),s=o_(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),f=s.slice(32,64).toString("hex"),u=`${t}.${i}`,c=new ws.SHA256().update(Buffer.from(u)).digest(),b=n_(e),v=Buffer.from(c).toString("hex");if(!b.verify(v,{r:o,s:f}))throw new Error("Invalid signature");return ts(r).payload}var a_="irn";function Rf(r){return r?.relay||{protocol:a_}}function As(r){let e=cb[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var f_=Object.defineProperty,c_=Object.defineProperties,h_=Object.getOwnPropertyDescriptors,bb=Object.getOwnPropertySymbols,u_=Object.prototype.hasOwnProperty,d_=Object.prototype.propertyIsEnumerable,vb=(r,e,t)=>e in r?f_(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,mb=(r,e)=>{for(var t in e||(e={}))u_.call(e,t)&&vb(r,t,e[t]);if(bb)for(var t of bb(e))d_.call(e,t)&&vb(r,t,e[t]);return r},l_=(r,e)=>c_(r,h_(e));function p_(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function Uu(r){if(!r.includes("wc:")){let u=Nb(r);u!=null&&u.includes("wc:")&&(r=u)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=ys.parse(s),f=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:g_(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:p_(o),methods:f,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function g_(r){return r.startsWith("//")?r.substring(2):r}function b_(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function zu(r){return`${r.protocol}:${r.topic}@${r.version}?`+ys.stringify(mb(l_(mb({symKey:r.symKey},b_(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Po(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function Rs(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function v_(r){let e=[];return Object.values(r).forEach(t=>{e.push(...Rs(t.accounts))}),e}function m_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.methods)}),t}function y_(r,e){let t=[];return Object.values(r).forEach(i=>{Rs(i.accounts).includes(e)&&t.push(...i.events)}),t}function w_(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function Bu(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=w_(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=N4(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var __={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},x_={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function X(r,e){let{message:t,code:i}=x_[r];return{message:e?`${t} ${e}`:t,code:i}}function Ue(r,e){let{message:t,code:i}=__[r];return{message:e?`${t} ${e}`:t,code:i}}function ji(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function No(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function vt(r){return typeof r>"u"}function Ye(r,e){return e&&vt(r)?!0:typeof r=="string"&&!!r.trim().length}function ku(r,e){return e&&vt(r)?!0:typeof r=="number"&&!isNaN(r)}function Wb(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return An(n,i)?(i.forEach(o=>{let{accounts:f,methods:u,events:c}=r.namespaces[o],b=Rs(f),v=t[o];(!An(Sb(o,v),b)||!An(v.methods,u)||!An(v.events,c))&&(s=!1)}),s):!1}function Ef(r){return Ye(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function E_(r){if(Ye(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ef(t)}}return!1}function Jb(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Ye(r,!1)){if(e(r))return!0;let t=Nb(r);return e(t)}}catch{}return!1}function Yb(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function Xb(r){return r?.topic}function Zb(r,e){let t=null;return Ye(r?.publicKey,!1)||(t=X("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function yb(r){let e=!0;return ji(r)?r.length&&(e=r.every(t=>Ye(t,!1))):e=!1,e}function S_(r,e,t){let i=null;return ji(e)&&e.length?e.forEach(n=>{i||Ef(n)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ef(r)||(i=Ue("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function I_(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=S_(n,Sb(n,s),`${e} ${t}`);o&&(i=o)}),i}function M_(r,e){let t=null;return ji(r)?r.forEach(i=>{t||E_(i)||(t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Ue("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function A_(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=M_(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function R_(r,e){let t=null;return yb(r?.methods)?yb(r?.events)||(t=Ue("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Ue("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Qb(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=R_(i,`${e}, namespace`);n&&(t=n)}),t}function ev(r,e,t){let i=null;if(r&&No(r)){let n=Qb(r,e);n&&(i=n);let s=I_(r,e,t);s&&(i=s)}else i=X("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Tf(r,e){let t=null;if(r&&No(r)){let i=Qb(r,e);i&&(t=i);let n=A_(r,e);n&&(t=n)}else t=X("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Ku(r){return Ye(r.protocol,!0)}function tv(r,e){let t=!1;return e&&!r?t=!0:r&&ji(r)&&r.length&&r.forEach(i=>{t=Ku(i)}),t}function rv(r){return typeof r=="number"}function Mt(r){return typeof r<"u"&&typeof r!==null}function iv(r){return!(!r||typeof r!="object"||!r.code||!ku(r.code,!1)||!r.message||!Ye(r.message,!1))}function nv(r){return!(vt(r)||!Ye(r.method,!1))}function sv(r){return!(vt(r)||vt(r.result)&&vt(r.error)||!ku(r.id,!1)||!Ye(r.jsonrpc,!1))}function ov(r){return!(vt(r)||!Ye(r.name,!1))}function ju(r,e){return!(!Ef(e)||!v_(r).includes(e))}function av(r,e,t){return Ye(t,!1)?m_(r,e).includes(t):!1}function fv(r,e,t){return Ye(t,!1)?y_(r,e).includes(t):!1}function Vu(r,e,t){let i=null,n=T_(r),s=D_(e),o=Object.keys(n),f=Object.keys(s),u=wb(Object.keys(r)),c=wb(Object.keys(e)),b=u.filter(v=>!c.includes(v));return b.length&&(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. + Required: ${b.toString()} + Received: ${Object.keys(e).toString()}`)),An(o,f)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. + Required: ${o.toString()} + Approved: ${f.toString()}`)),Object.keys(e).forEach(v=>{if(!v.includes(":")||i)return;let S=Rs(e[v].accounts);S.includes(v)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${v} + Required: ${v} + Approved: ${S.toString()}`))}),o.forEach(v=>{i||(An(n[v].methods,s[v].methods)?An(n[v].events,s[v].events)||(i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${v}`)):i=X("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${v}`))}),i}function T_(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function wb(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function D_(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:Rs(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function cv(r,e){return ku(r,!1)&&r<=e.max&&r>=e.min}function $u(){let r=Mo();return new Promise(e=>{switch(r){case Ft.browser:e(P_());break;case Ft.reactNative:e(N_());break;case Ft.node:e(C_());break;default:e(!0)}})}function P_(){return _s()&&navigator?.onLine}async function N_(){return Tn()&&typeof window<"u"&&window!=null&&window.NetInfo?(await window?.NetInfo.fetch())?.isConnected:!0}function C_(){return!0}function hv(r){switch(Mo()){case Ft.browser:O_(r);break;case Ft.reactNative:L_(r);break;case Ft.node:break}}function O_(r){!Tn()&&_s()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function L_(r){Tn()&&typeof window<"u"&&window!=null&&window.NetInfo&&window?.NetInfo.addEventListener(e=>r(e?.isConnected))}var xu={},Ki=class{static get(e){return xu[e]}static set(e,t){xu[e]=t}static delete(e){delete xu[e]}};var Mv=qe(un());var Rt={};Dt(Rt,{DEFAULT_ERROR:()=>Oo,IBaseJsonRpcProvider:()=>Uf,IEvents:()=>Lo,IJsonRpcConnection:()=>Yu,IJsonRpcProvider:()=>Fo,INTERNAL_ERROR:()=>Df,INVALID_PARAMS:()=>pv,INVALID_REQUEST:()=>dv,METHOD_NOT_FOUND:()=>lv,PARSE_ERROR:()=>uv,RESERVED_ERROR_CODES:()=>Hu,SERVER_ERROR:()=>Co,SERVER_ERROR_CODE_RANGE:()=>Pf,STANDARD_ERROR_MAP:()=>Vi,formatErrorMessage:()=>Sv,formatJsonRpcError:()=>Pn,formatJsonRpcRequest:()=>br,formatJsonRpcResult:()=>Ts,getBigIntRpcId:()=>gr,getError:()=>Cf,getErrorByCode:()=>Of,isHttpUrl:()=>H_,isJsonRpcError:()=>At,isJsonRpcPayload:()=>Zu,isJsonRpcRequest:()=>Ds,isJsonRpcResponse:()=>Gi,isJsonRpcResult:()=>kt,isJsonRpcValidationInvalid:()=>G_,isLocalhostUrl:()=>Xu,isNodeJs:()=>Ev,isReservedErrorCode:()=>Nf,isServerErrorCode:()=>F_,isValidDefaultRoute:()=>Ff,isValidErrorCode:()=>gv,isValidLeadingWildcardRoute:()=>k_,isValidRoute:()=>B_,isValidTrailingWildcardRoute:()=>K_,isValidWildcardRoute:()=>qf,isWsUrl:()=>zf,parseConnectionError:()=>Gu,payloadId:()=>Qr,validateJsonRpcError:()=>q_});var uv="PARSE_ERROR",dv="INVALID_REQUEST",lv="METHOD_NOT_FOUND",pv="INVALID_PARAMS",Df="INTERNAL_ERROR",Co="SERVER_ERROR",Hu=[-32700,-32600,-32601,-32602,-32603],Pf=[-32e3,-32099],Vi={[uv]:{code:-32700,message:"Parse error"},[dv]:{code:-32600,message:"Invalid Request"},[lv]:{code:-32601,message:"Method not found"},[pv]:{code:-32602,message:"Invalid params"},[Df]:{code:-32603,message:"Internal error"},[Co]:{code:-32e3,message:"Server error"}},Oo=Co;function F_(r){return r<=Pf[0]&&r>=Pf[1]}function Nf(r){return Hu.includes(r)}function gv(r){return typeof r=="number"}function Cf(r){return Object.keys(Vi).includes(r)?Vi[r]:Vi[Oo]}function Of(r){let e=Object.values(Vi).find(t=>t.code===r);return e||Vi[Oo]}function q_(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!gv(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if(Nf(r.error.code)){let e=Of(r.error.code);if(e.message!==Vi[Oo].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Gu(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var Nt={};Dt(Nt,{isNodeJs:()=>Ev});var xv=qe(Ju());qt(Nt,qe(Ju()));var Ev=xv.isNode;qt(Rt,Nt);function Qr(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function gr(r=6){return BigInt(Qr(r))}function br(r,e,t){return{id:t||Qr(),jsonrpc:"2.0",method:r,params:e}}function Ts(r,e){return{id:r,jsonrpc:"2.0",result:e}}function Pn(r,e,t){return{id:r,jsonrpc:"2.0",error:Sv(e,t)}}function Sv(r,e){return typeof r>"u"?Cf(Df):(typeof r=="string"&&(r=Object.assign(Object.assign({},Cf(Co)),{message:r})),typeof e<"u"&&(r.data=e),Nf(r.code)&&(r=Of(r.code)),r)}function B_(r){return r.includes("*")?qf(r):!/\W/g.test(r)}function Ff(r){return r==="*"}function qf(r){return Ff(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function k_(r){return!Ff(r)&&qf(r)&&!r.split("*")[0].trim()}function K_(r){return!Ff(r)&&qf(r)&&!r.split("*")[1].trim()}var Lo=class{},Yu=class extends Lo{constructor(e){super()}},Uf=class extends Lo{constructor(){super()}},Fo=class extends Uf{constructor(e){super()}};var j_="^https?:",V_="^wss?:";function $_(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Iv(r,e){let t=$_(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function H_(r){return Iv(r,j_)}function zf(r){return Iv(r,V_)}function Xu(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Zu(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function Ds(r){return Zu(r)&&"method"in r}function Gi(r){return Zu(r)&&(kt(r)||At(r))}function kt(r){return"result"in r}function At(r){return"error"in r}function G_(r){return"error"in r&&r.valid===!1}var Bf=class extends Fo{constructor(e){super(e),this.events=new Mv.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(br(e.method,e.params||[],e.id||gr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{At(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Gi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Pv=qe(un());var W_=()=>typeof WebSocket<"u"?WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Rv(),J_=()=>typeof WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Tv=r=>r.split("?")[0],Dv=10,Y_=W_(),kf=class{constructor(e){if(this.url=e,this.events=new Pv.EventEmitter,this.registering=!1,!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Wt(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!zf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Rt.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Xu(e)},o=new Y_(e,[],s);J_()?o.onerror=f=>{let u=f;i(this.emitError(u.error))}:o.on("error",f=>{i(this.emitError(f))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Fr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=Pn(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Gu(e,Tv(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Dv&&this.events.setMaxListeners(Dv)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Tv(this.url)}`));return this.events.emit("register_error",t),t}};var Om=qe(dm()),Lm=qe(za()),Fm="wc",qm=2,Ld="core",ii=`${Fm}@2:${Ld}:`,AE={name:Ld,logger:"error"},RE={database:":memory:"},TE="crypto",lm="client_ed25519_seed",DE=re.ONE_DAY,PE="keychain",NE="0.3",CE="messages",OE="0.3",LE=re.SIX_HOURS,FE="publisher",Fd="irn",qE="error",Um="wss://relay.walletconnect.org",UE="relayer",Tt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},zE="_subscription",rr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},BE=.1;var dd="2.17.2";var $e={link_mode:"link_mode",relay:"relay"},kE="0.3",KE="WALLETCONNECT_CLIENT_ID",pm="WALLETCONNECT_LINK_MODE_APPS",ti={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var jE="subscription",VE="0.3",$E=re.FIVE_SECONDS*1e3,HE="pairing",GE="0.3";var Ko={wc_pairingDelete:{req:{ttl:re.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:re.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:re.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:re.ONE_DAY,prompt:!1,tag:0},res:{ttl:re.ONE_DAY,prompt:!1,tag:0}}},Yi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},vr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},WE="history",JE="0.3",YE="expirer",Kt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},XE="0.3";var ZE="verify-api",QE="https://verify.walletconnect.com",zm="https://verify.walletconnect.org",Os=zm,e9=`${Os}/v3`,t9=[QE,zm],r9="echo",i9="https://echo.walletconnect.com";var mr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},ri={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},ir={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Xi={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Zi={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Ls={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},n9=.1,s9="event-client",o9=86400,a9="https://pulse.walletconnect.org/batch";function f9(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,U=new Uint8Array(B);P!==z;){for(var j=M[P],H=0,L=B-1;(j!==0||H>>0,U[L]=j%f>>>0,j=j/f>>>0;if(j!==0)throw new Error("Non-zero carry");O=H,P++}for(var C=B-O;C!==B&&U[C]===0;)C++;for(var W=u.repeat(T);C>>0,B=new Uint8Array(z);M[T];){var U=t[M.charCodeAt(T)];if(U===255)return;for(var j=0,H=z-1;(U!==0||j>>0,B[H]=U%256>>>0,U=U/256>>>0;if(U!==0)throw new Error("Non-zero carry");P=j,T++}if(M[T]!==" "){for(var L=z-P;L!==z&&B[L]===0;)L++;for(var C=new Uint8Array(O+(z-L)),W=O;L!==z;)C[W++]=B[L++];return C}}}function I(M){var T=S(M);if(T)return T;throw new Error(`Non-${e} character`)}return{encode:v,decodeUnsafe:S,decode:I}}var c9=f9,h9=c9,Bm=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},u9=r=>new TextEncoder().encode(r),d9=r=>new TextDecoder().decode(r),ld=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},pd=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return km(this,e)}},gd=class{constructor(e){this.decoders=e}or(e){return km(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},km=(r,e)=>new gd({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),bd=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new ld(e,t,i),this.decoder=new pd(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Qf=({name:r,prefix:e,encode:t,decode:i})=>new bd(r,e,t,i),$o=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=h9(t,e);return Qf({prefix:r,name:e,encode:i,decode:s=>Bm(n(s))})},l9=(r,e,t,i)=>{let n={};for(let b=0;b=8&&(f-=8,o[c++]=255&u>>f)}if(f>=t||255&u<<8-f)throw new SyntaxError("Unexpected end of data");return o},p9=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&f>>o];if(o&&(s+=e[n&f<Qf({prefix:e,name:r,encode(n){return p9(n,i,t)},decode(n){return l9(n,i,t,r)}}),g9=Qf({prefix:"\0",name:"identity",encode:r=>d9(r),decode:r=>u9(r)}),b9=Object.freeze({__proto__:null,identity:g9}),v9=mt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),m9=Object.freeze({__proto__:null,base2:v9}),y9=mt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),w9=Object.freeze({__proto__:null,base8:y9}),_9=$o({prefix:"9",name:"base10",alphabet:"0123456789"}),x9=Object.freeze({__proto__:null,base10:_9}),E9=mt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),S9=mt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),I9=Object.freeze({__proto__:null,base16:E9,base16upper:S9}),M9=mt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),A9=mt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),R9=mt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),T9=mt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),D9=mt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),P9=mt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),N9=mt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),C9=mt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),O9=mt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),L9=Object.freeze({__proto__:null,base32:M9,base32upper:A9,base32pad:R9,base32padupper:T9,base32hex:D9,base32hexupper:P9,base32hexpad:N9,base32hexpadupper:C9,base32z:O9}),F9=$o({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),q9=$o({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),U9=Object.freeze({__proto__:null,base36:F9,base36upper:q9}),z9=$o({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),B9=$o({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),k9=Object.freeze({__proto__:null,base58btc:z9,base58flickr:B9}),K9=mt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),j9=mt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),V9=mt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$9=mt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),H9=Object.freeze({__proto__:null,base64:K9,base64pad:j9,base64url:V9,base64urlpad:$9}),Km=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),G9=Km.reduce((r,e,t)=>(r[t]=e,r),[]),W9=Km.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function J9(r){return r.reduce((e,t)=>(e+=G9[t],e),"")}function Y9(r){let e=[];for(let t of r){let i=W9[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var X9=Qf({prefix:"\u{1F680}",name:"base256emoji",encode:J9,decode:Y9}),Z9=Object.freeze({__proto__:null,base256emoji:X9}),Q9=jm,gm=128,e7=127,t7=~e7,r7=Math.pow(2,31);function jm(r,e,t){e=e||[],t=t||0;for(var i=t;r>=r7;)e[t++]=r&255|gm,r/=128;for(;r&t7;)e[t++]=r&255|gm,r>>>=7;return e[t]=r|0,jm.bytes=t-i+1,e}var i7=vd,n7=128,bm=127;function vd(r,i){var t=0,i=i||0,n=0,s=i,o,f=r.length;do{if(s>=f)throw vd.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&bm)<=n7);return vd.bytes=s-i,t}var s7=Math.pow(2,7),o7=Math.pow(2,14),a7=Math.pow(2,21),f7=Math.pow(2,28),c7=Math.pow(2,35),h7=Math.pow(2,42),u7=Math.pow(2,49),d7=Math.pow(2,56),l7=Math.pow(2,63),p7=function(r){return r(Vm.encode(r,e,t),e),mm=r=>Vm.encodingLength(r),md=(r,e)=>{let t=e.byteLength,i=mm(r),n=i+mm(t),s=new Uint8Array(n+t);return vm(r,s,0),vm(t,s,i),s.set(e,n),new yd(r,t,e,s)},yd=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},$m=({name:r,code:e,encode:t})=>new wd(r,e,t),wd=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?md(this.code,t):t.then(i=>md(this.code,i))}else throw Error("Unknown type, must be binary type")}},Hm=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),b7=$m({name:"sha2-256",code:18,encode:Hm("SHA-256")}),v7=$m({name:"sha2-512",code:19,encode:Hm("SHA-512")}),m7=Object.freeze({__proto__:null,sha256:b7,sha512:v7}),Gm=0,y7="identity",Wm=Bm,w7=r=>md(Gm,Wm(r)),_7={code:Gm,name:y7,encode:Wm,digest:w7},x7=Object.freeze({__proto__:null,identity:_7});new TextEncoder,new TextDecoder;var ym={...b9,...m9,...w9,...x9,...I9,...L9,...U9,...k9,...H9,...Z9};({...m7,...x7});function E7(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function Jm(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var wm=Jm("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),hd=Jm("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=E7(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=X("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},xd=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=TE,this.randomSessionIdentifier=Af(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=_h(n);return Ua(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=Ub();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=_h(s),f=this.randomSessionIdentifier;return await fp(f,n,DE,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let f=this.getPrivateKey(n),u=zb(f,s);return this.setSymKey(u,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||Is(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let f=Lu(o),u=Wt(s);if(qu(f))return Kb(u,o?.encoding);if(Fu(f)){let S=f.senderPublicKey,I=f.receiverPublicKey;n=await this.generateSharedKey(S,I)}let c=this.getSymKey(n),{type:b,senderPublicKey:v}=f;return kb({type:b,symKey:c,message:u,senderPublicKey:v,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let f=Hb(s,o);if(qu(f)){let u=Vb(s,o?.encoding);return Fr(u)}if(Fu(f)){let u=f.receiverPublicKey,c=f.senderPublicKey;n=await this.generateSharedKey(u,c)}try{let u=this.getSymKey(n),c=jb({symKey:u,encoded:s,encoding:o?.encoding});return Fr(c)}catch(u){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(u)}},this.getPayloadType=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return ki(o.type)},this.getPayloadSenderPublicKey=(n,s=Zr)=>{let o=Ms({encoded:n,encoding:s});return o.senderPublicKey?Ze(o.senderPublicKey,It):void 0},this.core=e,this.logger=lt(t,this.name),this.keychain=i||new _d(this.core,this.logger)}get context(){return yt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(lm)}catch{e=Af(),await this.keychain.set(lm,e)}return I7(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Ed=class extends ba{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=CE,this.version=OE,this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=pr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=pr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=lt(e,this.name),this.core=t}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Iu(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Mu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Sd=class extends va{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Si.EventEmitter,this.name=FE,this.queue=new Map,this.publishTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.failedPublishTimeout=(0,re.toMiliseconds)(re.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let f=s?.ttl||LE,u=Rf(s),c=s?.prompt||!1,b=s?.tag||0,v=s?.id||gr().toString(),S={topic:i,message:n,opts:{ttl:f,relay:u,prompt:c,tag:b,id:v,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${v} tag:${b}`,M=Date.now(),T,O=1;try{for(;T===void 0;){if(Date.now()-M>this.publishTimeout)throw new Error(I);this.logger.trace({id:v,attempts:O},`publisher.publish - attempt ${O}`),T=await await Dn(this.rpcPublish(i,n,f,u,c,b,v,s?.attestation).catch(P=>this.logger.warn(P)),this.publishTimeout,I),O++,T||await new Promise(P=>setTimeout(P,this.failedPublishTimeout))}this.relayer.events.emit(Tt.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:v,topic:i,message:n,opts:s}})}catch(P){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(P),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw P;this.queue.set(v,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=lt(t,this.name),this.registerEventListeners()}get context(){return yt(this.logger)}rpcPublish(e,t,i,n,s,o,f,u){var c,b,v,S;let I={method:As(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:u},id:f};return vt((c=I.params)==null?void 0:c.prompt)&&((b=I.params)==null||delete b.prompt),vt((v=I.params)==null?void 0:v.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(dn.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Tt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Tt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},Id=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},M7=Object.defineProperty,A7=Object.defineProperties,R7=Object.getOwnPropertyDescriptors,_m=Object.getOwnPropertySymbols,T7=Object.prototype.hasOwnProperty,D7=Object.prototype.propertyIsEnumerable,xm=(r,e,t)=>e in r?M7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,jo=(r,e)=>{for(var t in e||(e={}))T7.call(e,t)&&xm(r,t,e[t]);if(_m)for(var t of _m(e))D7.call(e,t)&&xm(r,t,e[t]);return r},ud=(r,e)=>A7(r,R7(e)),Md=class extends wa{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Id,this.events=new Si.EventEmitter,this.name=jE,this.version=VE,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ii,this.subscribeTimeout=(0,re.toMiliseconds)(re.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=Rf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let f=await this.rpcSubscribe(i,s,n);return typeof f=="string"&&(this.onSubscribe(f,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),f}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let f=new re.Watch;f.start(n);let u=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(u),f.stop(n),s(!0)),f.elapsed(n)>=$E&&(clearInterval(u),f.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=lt(t,this.name),this.clientId=""}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=Rf(i);await this.rpcUnsubscribe(e,t,n);let s=Ue("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===$e.relay&&await this.restartToComplete();let s={method:As(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let f=pr(e+this.clientId);if(i?.transportType===$e.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(c=>this.logger.warn(c))},(0,re.toMiliseconds)(re.ONE_SECOND)),f;let u=await Dn(this.relayer.request(s).catch(c=>this.logger.warn(c)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return u?f:null}catch(f){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Tt.connection_stalled),o)throw f}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await Dn(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:As(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await Dn(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Tt.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:As(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,ud(jo({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,jo({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,jo({},t)),this.topicMap.set(t.topic,e),this.events.emit(ti.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(ti.deleted,ud(jo({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(ti.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);ji(t)&&this.onBatchSubscribe(t.map((i,n)=>ud(jo({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(dn.pulse,async()=>{await this.checkPending()}),this.events.on(ti.created,async e=>{let t=ti.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(ti.deleted,async e=>{let t=ti.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},P7=Object.defineProperty,Em=Object.getOwnPropertySymbols,N7=Object.prototype.hasOwnProperty,C7=Object.prototype.propertyIsEnumerable,Sm=(r,e,t)=>e in r?P7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Im=(r,e)=>{for(var t in e||(e={}))N7.call(e,t)&&Sm(r,t,e[t]);if(Em)for(var t of Em(e))C7.call(e,t)&&Sm(r,t,e[t]);return r},Ad=class extends ma{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Si.EventEmitter,this.name=UE,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,re.toMiliseconds)(re.THIRTY_SECONDS+re.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||gr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let f=await new Promise(async(u,c)=>{let b=()=>{c(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(rr.disconnect,b);let v=await o;this.provider.off(rr.disconnect,b),u(v)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),f}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(Io())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Tt.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Tt.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(rr.payload,this.onPayloadHandler),this.provider.on(rr.connect,this.onConnectHandler),this.provider.on(rr.disconnect,this.onDisconnectHandler),this.provider.on(rr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?lt(e.logger,this.name):(0,Hs.default)(Ws({level:e.logger||qE})),this.messages=new Ed(this.logger,e.core),this.subscriber=new Md(this,this.logger),this.publisher=new Sd(this,this.logger),this.relayUrl=e?.relayUrl||Um,this.projectId=e.projectId,this.bundleId=Ib(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return yt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:$e.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,f=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",u,c=b=>{b.topic===e&&(this.subscriber.off(ti.created,c),u())};return await Promise.all([new Promise(b=>{u=b,this.subscriber.on(ti.created,c)}),new Promise(async(b,v)=>{f=await this.subscriber.subscribe(e,Im({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&v(S)})||f,b()})]),f}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Dn(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(rr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(rr.disconnect,n),await Dn(this.provider.connect(),(0,re.toMiliseconds)(re.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await $u())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=st(re.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Tt.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(Io())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Bf(new kf(Mb({sdkVersion:dd,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ds(e)){if(!e.method.endsWith(zE))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,f={topic:i,message:n,publishedAt:s,transportType:$e.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Im({type:"event",event:t.id},f)),this.events.emit(t.id,f),await this.acknowledgePayload(e),await this.onMessageEvent(f)}else Gi(e)&&this.events.emit(Tt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Tt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=Ts(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(rr.payload,this.onPayloadHandler),this.provider.off(rr.connect,this.onConnectHandler),this.provider.off(rr.disconnect,this.onDisconnectHandler),this.provider.off(rr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await $u();hv(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Tt.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,re.toMiliseconds)(BE))))}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},O7=Object.defineProperty,Mm=Object.getOwnPropertySymbols,L7=Object.prototype.hasOwnProperty,F7=Object.prototype.propertyIsEnumerable,Am=(r,e,t)=>e in r?O7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Rm=(r,e)=>{for(var t in e||(e={}))L7.call(e,t)&&Am(r,t,e[t]);if(Mm)for(var t of Mm(e))F7.call(e,t)&&Am(r,t,e[t]);return r},ni=class extends ya{constructor(e,t,i,n=ii,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=kE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!vt(o)?this.map.set(this.getKey(o),o):Yb(o)?this.map.set(o.id,o):Xb(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,f)=>{this.isInitialized(),this.map.has(o)?await this.update(o,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:f}),this.map.set(o,f),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(f=>Object.keys(o).every(u=>(0,Om.default)(f[u],o[u]))):this.values),this.update=async(o,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:f});let u=Rm(Rm({},this.getData(o)),f);this.map.set(o,u),await this.persist()},this.delete=async(o,f)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:f}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=lt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Rd=class{constructor(e,t){this.core=e,this.logger=t,this.name=HE,this.version=GE,this.events=new Si.default,this.initialized=!1,this.storagePrefix=ii,this.ignoredPayloadTypes=[lr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=Af(),s=await this.core.crypto.setSymKey(n),o=st(re.FIVE_MINUTES),f={protocol:Fd},u={topic:s,expiry:o,relay:f,active:!1,methods:i?.methods},c=zu({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:f,expiryTimestamp:o,methods:i?.methods});return this.events.emit(Yi.create,u),this.core.expirer.set(s,o),await this.pairings.set(s,u),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:c}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[mr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:f,expiryTimestamp:u,methods:c}=Uu(i.uri);n.props.properties.topic=s,n.addTrace(mr.pairing_uri_validation_success),n.addTrace(mr.pairing_uri_not_expired);let b;if(this.pairings.keys.includes(s)){if(b=this.pairings.get(s),n.addTrace(mr.existing_pairing),b.active)throw n.setError(ri.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(mr.pairing_not_expired)}let v=u||st(re.FIVE_MINUTES),S={topic:s,relay:f,expiry:v,active:!1,methods:c};this.core.expirer.set(s,v),await this.pairings.set(s,S),n.addTrace(mr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(Yi.create,S),n.addTrace(mr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(mr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(ri.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:f})}catch(I){throw n.setError(ri.subscribe_pairing_topic_failure),I}return n.addTrace(mr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=st(re.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:f,reject:u}=_i();this.events.once(Oe("pairing_ping",s),({error:c})=>{c?u(c):f()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",Ue("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:f}=i,u=this.core.crypto.keychain.get(n);return zu({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:u,relay:s,expiryTimestamp:o,methods:f})},this.sendRequest=async(i,n,s)=>{let o=br(n,s),f=await this.core.crypto.encode(i,o),u=Ko[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,f,u),o.id},this.sendResult=async(i,n,s)=>{let o=Ts(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),c=Ko[u.request.method].res;await this.core.relayer.publish(n,f,c),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=Pn(i,s),f=await this.core.crypto.encode(n,o),u=await this.core.history.get(n,i),c=Ko[u.request.method]?Ko[u.request.method].res:Ko.unregistered_method.res;await this.core.relayer.publish(n,f,c),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Ue("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>Xr(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(Yi.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{kt(n)?this.events.emit(Oe("pairing_ping",s),{}):At(n)&&this.events.emit(Oe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Yi.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let f=Ue("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,f),this.logger.error(f)}catch(f){await this.sendError(s,i,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(Ue("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Mt(i)){let{message:f}=X("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!Jb(i.uri)){let{message:f}=X("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(ri.malformed_pairing_uri),new Error(f)}let o=Uu(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(!(o!=null&&o.symKey)){let{message:f}=X("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(ri.malformed_pairing_uri),new Error(f)}if(o!=null&&o.expiryTimestamp&&(0,re.toMiliseconds)(o?.expiryTimestamp){if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Mt(i)){let{message:s}=X("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!Ye(i,!1)){let{message:n}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(Xr(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=X("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=lt(t,this.name),this.pairings=new ni(this.core,this.logger,this.name,this.storagePrefix)}get context(){return yt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Tt.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===$e.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{Ds(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):Gi(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Kt.expired,async e=>{let{topic:t}=If(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Yi.expire,{topic:t}))})}},Td=class extends ga{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Si.EventEmitter,this.name=WE,this.version=JE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:st(re.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(vr.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=At(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(vr.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(vr.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:br(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(vr.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(vr.created,e=>{let t=vr.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.updated,e=>{let t=vr.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(vr.deleted,e=>{let t=vr.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(dn.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,re.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(vr.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Dd=class extends _a{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Si.EventEmitter,this.name=YE,this.version=XE,this.cached=[],this.initialized=!1,this.storagePrefix=ii,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Kt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Kt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=lt(t,this.name)}get context(){return yt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Rb(e);if(typeof e=="number")return Tb(e);let{message:t}=X("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Kt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=X("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=X("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,re.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Kt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(dn.pulse,()=>this.checkExpirations()),this.events.on(Kt.created,e=>{let t=Kt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.expired,e=>{let t=Kt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Kt.deleted,e=>{let t=Kt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}},Pd=class extends xa{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=ZE,this.verifyUrlV3=e9,this.storagePrefix=ii,this.version=qm,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,re.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!_s()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:f}=n,u=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${f}`;try{let c=(0,Lm.getDocument)(),b=this.startAbortTimer(re.ONE_SECOND*5),v=await new Promise((S,I)=>{let M=()=>{window.removeEventListener("message",O),c.body.removeChild(T),I("attestation aborted")};this.abortController.signal.addEventListener("abort",M);let T=c.createElement("iframe");T.src=u,T.style.display="none",T.addEventListener("error",M,{signal:this.abortController.signal});let O=P=>{if(P.data&&typeof P.data=="string")try{let z=JSON.parse(P.data);if(z.type==="verify_attestation"){if(ts(z.attestation).payload.id!==o)return;clearInterval(b),c.body.removeChild(T),this.abortController.signal.removeEventListener("abort",M),window.removeEventListener("message",O),S(z.attestation===null?"":z.attestation)}}catch(z){this.logger.warn(z)}};c.body.appendChild(T),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",v),v}catch(c){this.logger.warn(c)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:f}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(ts(s).payload.id!==f)return;let c=await this.isValidJwtAttestation(s);if(c){if(!c.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return c}}if(!o)return;let u=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,u)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(re.ONE_SECOND*5),f=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),f.status===200?await f.json():void 0},this.getVerifyUrl=n=>{let s=n||Os;return t9.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${Os}`),s=Os),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(re.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(f){this.logger.error(f),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=Gb(n,s.publicKey),f={hasExpired:(0,re.toMiliseconds)(o.exp)this.abortController.abort(),(0,re.toMiliseconds)(e))}},Nd=class extends Ea{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=r9,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:f=!1}=i,u=`${i9}/${this.projectId}/clients`;await fetch(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:f})})},this.logger=lt(t,this.context)}},q7=Object.defineProperty,Tm=Object.getOwnPropertySymbols,U7=Object.prototype.hasOwnProperty,z7=Object.prototype.propertyIsEnumerable,Dm=(r,e,t)=>e in r?q7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Vo=(r,e)=>{for(var t in e||(e={}))U7.call(e,t)&&Dm(r,t,e[t]);if(Tm)for(var t of Tm(e))z7.call(e,t)&&Dm(r,t,e[t]);return r},Cd=class extends Sa{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=s9,this.storagePrefix=ii,this.storageVersion=n9,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!Ao())try{let n={eventId:Ru(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Su(this.core.relayer.protocol,this.core.relayer.version,dd)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:f,trace:u}}=n,c=Ru(),b=this.core.projectId||"",v=Date.now(),S=Vo({eventId:c,timestamp:v,props:{event:s,type:o,properties:{topic:f,trace:u}},bundleId:b,domain:this.getAppDomain()},this.setMethods(c));return this.telemetryEnabled&&(this.events.set(c,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let f=Array.from(this.events.values()).find(u=>u.props.properties.topic===o);if(f)return Vo(Vo({},f),this.setMethods(f.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(dn.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,re.fromMiliseconds)(Date.now())-(0,re.fromMiliseconds)(n.timestamp)>o9&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Vo(Vo({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${a9}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${dd}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>xs().url,this.logger=lt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},B7=Object.defineProperty,Pm=Object.getOwnPropertySymbols,k7=Object.prototype.hasOwnProperty,K7=Object.prototype.propertyIsEnumerable,Nm=(r,e,t)=>e in r?B7(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cm=(r,e)=>{for(var t in e||(e={}))k7.call(e,t)&&Nm(r,t,e[t]);if(Pm)for(var t of Pm(e))K7.call(e,t)&&Nm(r,t,e[t]);return r},Od=class r extends pa{constructor(e){var t;super(e),this.protocol=Fm,this.version=qm,this.name=Ld,this.events=new Si.EventEmitter,this.initialized=!1,this.on=(o,f)=>this.events.on(o,f),this.once=(o,f)=>this.events.once(o,f),this.off=(o,f)=>this.events.off(o,f),this.removeListener=(o,f)=>this.events.removeListener(o,f),this.dispatchEnvelope=({topic:o,message:f,sessionExists:u})=>{if(!o||!f)return;let c={topic:o,message:f,publishedAt:Date.now(),transportType:$e.link_mode};this.relayer.onLinkMessageEvent(c,{sessionExists:u})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Um,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Ws({level:typeof e?.logger=="string"&&e.logger?e.logger:AE.logger}),{logger:n,chunkLoggerController:s}=Zl({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,f;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((f=this.logChunkController)==null||f.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=lt(n,this.name),this.heartbeat=new na,this.crypto=new xd(this,this.logger,e?.keychain),this.history=new Td(this,this.logger),this.expirer=new Dd(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new aa(Cm(Cm({},RE),e?.storageOptions)),this.relayer=new Ad({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Rd(this,this.logger),this.verify=new Pd(this,this.logger,this.storage),this.echoClient=new Nd(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Cd(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(KE,i),t}get context(){return yt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(pm,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(pm)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},Ym=Od;var rc=qe(un()),Fe=qe(jn());var ey="wc",ty=2,ry="client",Gd=`${ey}@${ty}:${ry}:`,qd={name:ry,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var Xm="WALLETCONNECT_DEEPLINK_CHOICE";var j7="proposal";var V7="Proposal expired",$7="session",Fs=Fe.SEVEN_DAYS,H7="engine",dt={wc_sessionPropose:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:Fe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:Fe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:Fe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:Fe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:Fe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:Fe.FIVE_MINUTES,prompt:!1,tag:1119}}},Ud={min:Fe.FIVE_MINUTES,max:Fe.SEVEN_DAYS},si={idle:"IDLE",active:"ACTIVE"},G7="request",W7=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],J7="wc";var Y7="auth",X7="authKeys",Z7="pairingTopics",Q7="requests",ic=`${J7}@${1.5}:${Y7}:`,ec=`${ic}:PUB_KEY`,eS=Object.defineProperty,tS=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,Zm=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,nS=Object.prototype.propertyIsEnumerable,Qm=(r,e,t)=>e in r?eS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,tt=(r,e)=>{for(var t in e||(e={}))iS.call(e,t)&&Qm(r,t,e[t]);if(Zm)for(var t of Zm(e))nS.call(e,t)&&Qm(r,t,e[t]);return r},yr=(r,e)=>tS(r,rS(e)),zd=class extends Ma{constructor(e){super(e),this.name=H7,this.events=new rc.default,this.initialized=!1,this.requestQueue={state:si.idle,queue:[]},this.sessionRequestQueue={state:si.idle,queue:[]},this.requestQueueDelay=Fe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(dt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=yr(tt({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:f,relays:u}=i,c=n,b,v=!1;try{c&&(v=this.client.core.pairing.pairings.get(c).active)}catch(U){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),U}if(!c||!v){let{topic:U,uri:j}=await this.client.core.pairing.create();c=U,b=j}if(!c){let{message:U}=X("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(U)}let S=await this.client.core.crypto.generateKeyPair(),I=dt.wc_sessionPropose.req.ttl||Fe.FIVE_MINUTES,M=st(I),T=tt({requiredNamespaces:s,optionalNamespaces:o,relays:u??[{protocol:Fd}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:M,pairingTopic:c},f&&{sessionProperties:f}),{reject:O,resolve:P,done:z}=_i(I,V7);this.events.once(Oe("session_connect"),async({error:U,session:j})=>{if(U)O(U);else if(j){j.self.publicKey=S;let H=yr(tt({},j),{pairingTopic:T.pairingTopic,requiredNamespaces:T.requiredNamespaces,optionalNamespaces:T.optionalNamespaces,transportType:$e.relay});await this.client.session.set(j.topic,H),await this.setExpiry(j.topic,j.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(H),P(H)}});let B=await this.sendRequest({topic:c,method:"wc_sessionPropose",params:T,throwOnFailedPublish:!0});return await this.setProposal(B,tt({id:B},T)),{uri:b,approval:z}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[ir.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(C){throw o.setError(Xi.no_internet_connection),C}try{await this.isValidProposalId(t?.id)}catch(C){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(Xi.proposal_not_found),C}try{await this.isValidApprove(t)}catch(C){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(Xi.session_approve_namespace_validation_failure),C}let{id:f,relayProtocol:u,namespaces:c,sessionProperties:b,sessionConfig:v}=t,S=this.client.proposal.get(f);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:M,requiredNamespaces:T,optionalNamespaces:O}=S,P=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});P||(P=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:ir.session_approve_started,properties:{topic:I,trace:[ir.session_approve_started,ir.session_namespaces_validation_success]}}));let z=await this.client.core.crypto.generateKeyPair(),B=M.publicKey,U=await this.client.core.crypto.generateSharedKey(z,B),j=tt(tt({relay:{protocol:u??"irn"},namespaces:c,controller:{publicKey:z,metadata:this.client.metadata},expiry:st(Fs)},b&&{sessionProperties:b}),v&&{sessionConfig:v}),H=$e.relay;P.addTrace(ir.subscribing_session_topic);try{await this.client.core.relayer.subscribe(U,{transportType:H})}catch(C){throw P.setError(Xi.subscribe_session_topic_failure),C}P.addTrace(ir.subscribe_session_topic_success);let L=yr(tt({},j),{topic:U,requiredNamespaces:T,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:M.publicKey,metadata:M.metadata},controller:z,transportType:$e.relay});await this.client.session.set(U,L),P.addTrace(ir.store_session);try{P.addTrace(ir.publishing_session_settle),await this.sendRequest({topic:U,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(C=>{throw P?.setError(Xi.session_settle_publish_failure),C}),P.addTrace(ir.session_settle_publish_success),P.addTrace(ir.publishing_session_approve),await this.sendResult({id:f,topic:I,result:{relay:{protocol:u??"irn"},responderPublicKey:z},throwOnFailedPublish:!0}).catch(C=>{throw P?.setError(Xi.session_approve_publish_failure),C}),P.addTrace(ir.session_approve_publish_success)}catch(C){throw this.client.logger.error(C),this.client.session.delete(U,Ue("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(U),C}return this.client.core.eventClient.deleteEvent({eventId:P.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:M.metadata}),await this.client.proposal.delete(f,Ue("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(U,st(Fs)),{topic:U,acknowledged:()=>Promise.resolve(this.client.session.get(U))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:dt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(v){throw this.client.logger.error("update() -> isValidUpdate() failed"),v}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:f}=_i(),u=Qr(),c=gr().toString(),b=this.client.session.get(i).namespaces;return this.events.once(Oe("session_update",u),({error:v})=>{v?f(v):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:u,relayRpcId:c}).catch(v=>{this.client.logger.error(v),this.client.session.update(i,{namespaces:b}),f(v)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(u){throw this.client.logger.error("extend() -> isValidExtend() failed"),u}let{topic:i}=t,n=Qr(),{done:s,resolve:o,reject:f}=_i();return this.events.once(Oe("session_extend",n),({error:u})=>{u?f(u):o()}),await this.setExpiry(i,st(Fs)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(u=>{f(u)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(M){throw this.client.logger.error("request() -> isValidRequest() failed"),M}let{chainId:i,request:n,topic:s,expiry:o=dt.wc_sessionRequest.req.ttl}=t,f=this.client.session.get(s);f?.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let u=Qr(),c=gr().toString(),{done:b,resolve:v,reject:S}=_i(o,"Request expired. Please try again.");this.events.once(Oe("session_request",u),({error:M,result:T})=>{M?S(M):v(T)});let I=this.getAppLinkIfEnabled(f.peer.metadata,f.transportType);return I?(await this.sendRequest({clientRpcId:u,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(M=>S(M)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),await b()):await Promise.all([new Promise(async M=>{await this.sendRequest({clientRpcId:u,relayRpcId:c,topic:s,method:"wc_sessionRequest",params:{request:yr(tt({},n),{expiryTimestamp:st(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(T=>S(T)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:u}),M()}),new Promise(async M=>{var T;if(!((T=f.sessionConfig)!=null&&T.disableDeepLink)){let O=await Pb(this.client.core.storage,Xm);await Db({id:u,topic:s,wcDeepLink:O})}M()}),b()]).then(M=>M[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);kt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:f}):At(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:f}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=Qr(),s=gr().toString(),{done:o,resolve:f,reject:u}=_i();this.events.once(Oe("session_ping",n),({error:c})=>{c?u(c):f()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=gr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Ue("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=X("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>Wb(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?$e.link_mode:$e.relay;o===$e.relay&&await this.confirmOnlineStateOrThrow();let{chains:f,statement:u="",uri:c,domain:b,nonce:v,type:S,exp:I,nbf:M,methods:T=[],expiry:O}=t,P=[...t.resources||[]],{topic:z,uri:B}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:z,uri:B}});let U=await this.client.core.crypto.generateKeyPair(),j=Is(U);if(await Promise.all([this.client.auth.authKeys.set(ec,{responseTopic:j,publicKey:U}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:z})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${z}`),T.length>0){let{namespace:y}=So(f[0]),h=Ob(y,"request",T);To(P)&&(h=Lb(h,P.pop())),P.push(h)}let H=O&&O>dt.wc_sessionAuthenticate.req.ttl?O:dt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:f,statement:u,aud:c,domain:b,version:"1",nonce:v,iat:new Date().toISOString(),exp:I,nbf:M,resources:P},requester:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:st(H)},C={eip155:{chains:f,methods:[...new Set(["personal_sign",...T])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:z,proposer:{publicKey:U,metadata:this.client.metadata},expiryTimestamp:st(dt.wc_sessionPropose.req.ttl)},{done:D,resolve:l,reject:w}=_i(H,"Request expired"),p=async({error:y,session:h})=>{if(this.events.off(Oe("session_request",d),a),y)w(y);else if(h){h.self.publicKey=U,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:h.peer.metadata});let x=this.client.session.get(h.topic);await this.deleteProposal(m),l({session:x})}},a=async y=>{var h,x,A;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),y.error){let q=Ue("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return y.error.code===q.code?void 0:(this.events.off(Oe("session_connect"),p),w(y.error.message))}await this.deleteProposal(m),this.events.off(Oe("session_connect"),p);let{cacaos:g,responder:R}=y.result,k=[],E=[];for(let q of g){await Du({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,J=To(K.resources),$=[Mf(K.iss)],V=Ro(K.iss);if(J){let ee=Nu(J),G=Cu(J);k.push(...ee),$.push(...G)}for(let ee of $)E.push(`${ee}:${V}`)}let N=await this.client.core.crypto.generateSharedKey(U,R.publicKey),F;k.length>0&&(F={topic:N,acknowledged:!0,self:{publicKey:U,metadata:this.client.metadata},peer:R,controller:R.publicKey,expiry:st(Fs),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:z,namespaces:Bu([...new Set(k)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(N,{transportType:o}),await this.client.session.set(N,F),z&&await this.client.core.pairing.updateMetadata({topic:z,metadata:R.metadata}),F=this.client.session.get(N)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(x=R.metadata.redirect)!=null&&x.linkMode&&(A=R.metadata.redirect)!=null&&A.universal&&i&&(this.client.core.addLinkModeSupportedApp(R.metadata.redirect.universal),this.client.session.update(N,{transportType:$e.link_mode})),l({auths:g,session:F})},d=Qr(),m=Qr();this.events.once(Oe("session_connect"),p),this.events.once(Oe("session_request",d),a);let _;try{if(s){let y=br("wc_sessionAuthenticate",L,d);this.client.core.history.set(z,y);let h=await this.client.core.crypto.encode("",y,{type:Ss,encoding:Es});_=Po(i,z,h)}else await Promise.all([this.sendRequest({topic:z,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:z,method:"wc_sessionPropose",params:W,expiry:dt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:m})])}catch(y){throw this.events.off(Oe("session_connect"),p),this.events.off(Oe("session_request",d),a),y}return await this.setProposal(m,tt({id:m},W)),await this.setAuthRequest(d,{request:yr(tt({},L),{verifyContext:{}}),pairingTopic:z,transportType:o}),{uri:_??B,response:D}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Zi.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(Ls.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(Ls.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let f=o.transportType||$e.relay;f===$e.relay&&await this.confirmOnlineStateOrThrow();let u=o.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),b=Is(u),v={type:lr,receiverPublicKey:u,senderPublicKey:c},S=[],I=[];for(let O of n){if(!await Du({cacao:O,projectId:this.client.core.projectId})){s.setError(Ls.invalid_cacao);let j=Ue("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:b,error:j,encodeOpts:v}),new Error(j.message)}s.addTrace(Zi.cacaos_verified);let{p:P}=O,z=To(P.resources),B=[Mf(P.iss)],U=Ro(P.iss);if(z){let j=Nu(z),H=Cu(z);S.push(...j),B.push(...H)}for(let j of B)I.push(`${j}:${U}`)}let M=await this.client.core.crypto.generateSharedKey(c,u);s.addTrace(Zi.create_authenticated_session_topic);let T;if(S?.length>0){T={topic:M,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:u,metadata:o.requester.metadata},controller:u,expiry:st(Fs),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Bu([...new Set(S)],[...new Set(I)]),transportType:f},s.addTrace(Zi.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(M,{transportType:f})}catch(O){throw s.setError(Ls.subscribe_authenticated_session_topic_failure),O}s.addTrace(Zi.subscribe_authenticated_session_topic_success),await this.client.session.set(M,T),s.addTrace(Zi.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(Zi.publishing_authenticated_session_approve);try{await this.sendResult({topic:b,id:i,result:{cacaos:n,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:v,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,f)})}catch(O){throw s.setError(Ls.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:T}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===$e.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,f=await this.client.core.crypto.generateKeyPair(),u=Is(o),c={type:lr,receiverPublicKey:o,senderPublicKey:f};await this.sendError({id:i,topic:u,error:n,encodeOpts:c,rpcOpts:dt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Ue("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return Pu(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,f;return((o=s.peerMetadata)==null?void 0:o.url)&&((f=s.peerMetadata)==null?void 0:f.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:f=0}=t,{self:u}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,Ue("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(u.publicKey)&&await this.client.core.crypto.deleteKeyPair(u.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Xm).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===n&&this.deletePendingSessionRequest(c.id,Ue("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=si.idle),o&&this.client.events.emit("session_delete",{id:f,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(Xi.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Ue("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=si.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,st(dt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=$e.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,f=s.request.expiryTimestamp||st(dt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,f),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:f,clientRpcId:u,throwOnFailedPublish:c,appLink:b}=t,v=br(n,s,u),S,I=!!b;try{let O=I?Es:Zr;S=await this.client.core.crypto.encode(i,v,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let M;if(W7.includes(n)){let O=pr(JSON.stringify(v)),P=pr(S);M=await this.client.core.verify.register({id:P,decryptedId:O})}let T=dt[n].req;if(T.attestation=M,o&&(T.ttl=o),f&&(T.id=f),this.client.core.history.set(i,v),I){let O=Po(b,i,S);await window.Linking.openURL(O,this.client.name)}else{let O=dt[n].req;o&&(O.ttl=o),f&&(O.id=f),c?(O.internal=yr(tt({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(P=>this.client.logger.error(P))}return v.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:f,appLink:u}=t,c=Ts(i,s),b,v=u&&typeof window?.Linking<"u";try{let I=v?Es:Zr;b=await this.client.core.crypto.encode(n,c,yr(tt({},f||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(v){let I=Po(u,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=dt[S.request.method].res;o?(I.internal=yr(tt({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,b,I)):this.client.core.relayer.publish(n,b,I).catch(M=>this.client.logger.error(M))}await this.client.core.history.resolve(c)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:f,appLink:u}=t,c=Pn(i,s),b,v=u&&typeof window?.Linking<"u";try{let I=v?Es:Zr;b=await this.client.core.crypto.encode(n,c,yr(tt({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(v){let I=Po(u,n,b);await window.Linking.openURL(I,this.client.name)}else{let I=f||dt[S.request.method].res;this.client.core.relayer.publish(n,b,I)}await this.client.core.history.resolve(c)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;Xr(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{Xr(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===si.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=si.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=si.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:f}=t,u=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:u}))switch(u){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:f});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:f,transportType:o});default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=X("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:f,id:u}=n;try{let c=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(tt({},n.params));let b=f.expiryTimestamp||st(dt.wc_sessionPropose.req.ttl),v=tt({id:u,pairingTopic:i,expiryTimestamp:b},f);await this.setProposal(u,v);let S=await this.getVerifyContext({attestationId:s,hash:pr(JSON.stringify(n)),encryptedId:o,metadata:v.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),c?.setError(ri.proposal_listener_not_found)),c?.addTrace(mr.emit_session_proposal),this.client.events.emit("session_proposal",{id:u,params:v,verifyContext:S})}catch(c){await this.sendError({id:u,topic:i,error:c,rpcOpts:dt.wc_sessionPropose.autoReject}),this.client.logger.error(c)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(kt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let f=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});let u=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});let c=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:c});let b=await this.client.core.crypto.generateSharedKey(u,c);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});let v=await this.client.core.relayer.subscribe(b,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:v}),await this.client.core.pairing.activate({topic:t})}else if(At(i)){await this.client.proposal.delete(s,Ue("USER_DISCONNECTED"));let o=Oe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Oe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:f,expiry:u,namespaces:c,sessionProperties:b,sessionConfig:v}=i.params,S=yr(tt(tt({topic:t,relay:o,expiry:u,namespaces:c,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},b&&{sessionProperties:b}),v&&{sessionConfig:v}),{transportType:$e.relay}),I=Oe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Oe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;kt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Oe("session_approve",n),{})):At(i)&&(await this.client.session.delete(t,Ue("USER_DISCONNECTED")),this.events.emit(Oe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,f=Ki.get(o);if(f&&this.isRequestOutOfSync(f,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:Ue("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(tt({topic:t},n));try{Ki.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(u){throw Ki.delete(o),u}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Oe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_update",n),{}):At(i)&&this.events.emit(Oe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,st(Fs)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Oe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_extend",n),{}):At(i)&&this.events.emit(Oe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Oe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{kt(i)?this.events.emit(Oe("session_ping",n),{}):At(i)&&this.events.emit(Oe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Tt.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Ue("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:f,attestation:u,encryptedId:c,transportType:b}=t,{id:v,params:S}=f;try{await this.isValidRequest(tt({topic:o},S));let I=this.client.session.get(o),M=await this.getVerifyContext({attestationId:u,hash:pr(JSON.stringify(br("wc_sessionRequest",S,v))),encryptedId:c,metadata:I.peer.metadata,transportType:b}),T={id:v,topic:o,params:S,verifyContext:M};await this.setPendingSessionRequest(T),b===$e.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(T):(this.addSessionRequestToSessionRequestQueue(T),this.processSessionRequestQueue())}catch(I){await this.sendError({id:v,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Oe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,f=Ki.get(o);if(f&&this.isRequestOutOfSync(f,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(tt({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),Ki.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),kt(i)?this.events.emit(Oe("session_request",n),{result:i.result}):At(i)&&this.events.emit(Oe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:f,transportType:u}=t;try{let{requester:c,authPayload:b,expiryTimestamp:v}=s.params,S=await this.getVerifyContext({attestationId:o,hash:pr(JSON.stringify(s)),encryptedId:f,metadata:c.metadata,transportType:u}),I={requester:c,pairingTopic:n,id:s.id,authPayload:b,verifyContext:S,expiryTimestamp:v};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:u}),u===$e.link_mode&&(i=c.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(c){this.client.logger.error(c);let b=s.params.requester.publicKey,v=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,u),I={type:lr,receiverPublicKey:b,senderPublicKey:v};await this.sendError({id:s.id,topic:n,error:c,encodeOpts:I,rpcOpts:dt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=si.idle,this.processSessionRequestQueue()},(0,Fe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,f=Oe("session_request",o);if(this.events.listenerCount(f)===0)throw new Error(`emitting ${f} without any listeners`);this.events.emit(Oe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===si.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=si.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:br("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Mt(t)){let{message:u}=X("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(u)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:f}=t;if(vt(i)||await this.isValidPairingTopic(i),!tv(f,!0)){let{message:u}=X("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(u)}!vt(n)&&No(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!vt(s)&&No(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),vt(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=ev(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Mt(t))throw new Error(X("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let f=this.client.proposal.get(i),u=Tf(n,"approve()");if(u)throw new Error(u.message);let c=Vu(f.requiredNamespaces,n,"approve()");if(c)throw new Error(c.message);if(!Ye(s,!0)){let{message:b}=X("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(b)}vt(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Mt(t)){let{message:s}=X("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!iv(n)){let{message:s}=X("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Mt(t)){let{message:c}=X("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(c)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!Ku(i)){let{message:c}=X("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}let f=Zb(n,"onSessionSettleRequest()");if(f)throw new Error(f.message);let u=Tf(s,"onSessionSettleRequest()");if(u)throw new Error(u.message);if(Xr(o)){let{message:c}=X("EXPIRED","onSessionSettleRequest()");throw new Error(c)}},this.isValidUpdate=async t=>{if(!Mt(t)){let{message:u}=X("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(u)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=Tf(n,"update()");if(o)throw new Error(o.message);let f=Vu(s.requiredNamespaces,n,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Mt(t)){let{message:u}=X("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(u)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:f}=this.client.session.get(i);if(!ju(f,s)){let{message:u}=X("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!nv(n)){let{message:u}=X("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(u)}if(!av(f,s,n.method)){let{message:u}=X("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(u)}if(o&&!cv(o,Ud)){let{message:u}=X("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Ud.min} and ${Ud.max}`);throw new Error(u)}},this.isValidRespond=async t=>{var i;if(!Mt(t)){let{message:o}=X("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!sv(s)){let{message:o}=X("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Mt(t)){let{message:f}=X("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(f)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!ju(o,s)){let{message:f}=X("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(f)}if(!ov(n)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}if(!fv(o,s,n.name)){let{message:f}=X("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(f)}},this.isValidDisconnect=async t=>{if(!Mt(t)){let{message:n}=X("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Ye(n,!1))throw new Error("uri is required parameter");if(!Ye(s,!1))throw new Error("domain is required parameter");if(!Ye(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(u=>So(u).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:f}=So(i[0]);if(f!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:f}=t,u={verified:{verifyUrl:o.verifyUrl||Os,validation:"UNKNOWN",origin:o.url||""}};try{if(f===$e.link_mode){let b=this.getAppLinkIfEnabled(o,f);return u.verified.validation=b&&new URL(b).origin===new URL(o.url).origin?"VALID":"INVALID",u}let c=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});c&&(u.verified.origin=c.origin,u.verified.isScam=c.isScam,u.verified.validation=c.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(c){this.client.logger.warn(c)}return this.client.logger.debug(`Verify context: ${JSON.stringify(u)}`),u},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!Ye(n,!1)){let{message:s}=X("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=X("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,f,u,c,b,v,S;return!t||i!==$e.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((f=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:f.universal)!==void 0&&((c=(u=this.client.metadata)==null?void 0:u.redirect)==null?void 0:c.universal)!==""&&((b=t?.redirect)==null?void 0:b.universal)!==void 0&&((v=t?.redirect)==null?void 0:v.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof window?.Linking<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=Au(t,"topic")||"",n=decodeURIComponent(Au(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:$e.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(Ao()||Tn()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=window?.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=X("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Tt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(ec)?this.client.auth.authKeys.get(ec):{responseTopic:void 0,publicKey:void 0},f=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===$e.link_mode?Es:Zr});try{Ds(f)?(this.client.core.history.set(t,f),this.onRelayEventRequest({topic:t,payload:f,attestation:n,transportType:s,encryptedId:pr(i)})):Gi(f)?(await this.client.core.history.resolve(f),await this.onRelayEventResponse({topic:t,payload:f,transportType:s}),this.client.core.history.delete(t,f.id)):this.onRelayEventUnknownPayload({topic:t,payload:f,transportType:s})}catch(u){this.client.logger.error(u)}}registerExpirerEvents(){this.client.core.expirer.on(Kt.expired,async e=>{let{topic:t,id:i}=If(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,X("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,X("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Yi.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Yi.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=X("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Ye(e,!1)){let{message:t}=X("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=X("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=X("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Ye(e,!1)){let{message:t}=X("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=X("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!rv(e)){let{message:t}=X("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=X("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(Xr(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=X("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},Bd=class extends ni{constructor(e,t){super(e,t,j7,Gd),this.core=e,this.logger=t}},kd=class extends ni{constructor(e,t){super(e,t,$7,Gd),this.core=e,this.logger=t}},Kd=class extends ni{constructor(e,t){super(e,t,G7,Gd,i=>i.id),this.core=e,this.logger=t}},jd=class extends ni{constructor(e,t){super(e,t,X7,ic,()=>ec),this.core=e,this.logger=t}},Vd=class extends ni{constructor(e,t){super(e,t,Z7,ic),this.core=e,this.logger=t}},$d=class extends ni{constructor(e,t){super(e,t,Q7,ic,i=>i.id),this.core=e,this.logger=t}},Hd=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new jd(this.core,this.logger),this.pairingTopics=new Vd(this.core,this.logger),this.requests=new $d(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},tc=class r extends Ia{constructor(e){super(e),this.protocol=ey,this.version=ty,this.name=qd.name,this.events=new rc.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||qd.name,this.metadata=e?.metadata||xs(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,Hs.default)(Ws({level:e?.logger||qd.logger}));this.core=e?.core||new Ym(e),this.logger=lt(t,this.name),this.session=new kd(this.core,this.logger),this.proposal=new Bd(this.core,this.logger),this.pendingRequest=new Kd(this.core,this.logger),this.engine=new zd(this),this.auth=new Hd(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return yt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};var iy=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],wr="mvx";var Ho=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);function Wd(r){return r[Math.floor(Math.random()*r.length)]}var ny="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Jd=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;ti.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function Ii(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=Xd(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function sy(r){return!!r}function Zd(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function Qd({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,f=r.guardian;if(f&&f!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=Jd(t),i&&(r.guardianSignature=Jd(i)),r}function oy(r){if(r)return{...r,url:xs().url}}async function ay(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var oi=class{constructor(e,t,i,n,s,o,f,u){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.Message=s,this.Transaction=o,this.TransactionsConverter=f,this.options=u}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:oy(this.options?.metadata)}:{},t=await tc.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=Yd(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await ay(500);let i=Zd(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||Ii(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:Ue("USER_DISCONNECTED")});else{let t=Ii(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:Ue("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new this.Message({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=this.TransactionsConverter.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return Qd({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return this.TransactionsConverter.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];Qd({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:Ii(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=Ii(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?sy(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=Zd(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&Ii(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=Xd(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!ji(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var Fn=(r=>(r[r.Border=-1]="Border",r[r.Data=0]="Data",r[r.Function=1]="Function",r[r.Position=2]="Position",r[r.Timing=3]="Timing",r[r.Alignment=4]="Alignment",r))(Fn||{}),aS=Object.defineProperty,fS=(r,e,t)=>e in r?aS(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,nc=(r,e,t)=>(fS(r,typeof e!="symbol"?e+"":e,t),t),cS=[0,1],cy=[1,0],hy=[2,3],uy=[3,2],hS={L:cS,M:cy,Q:hy,H:uy},uS=/^[0-9]*$/,dS=/^[A-Z0-9 $%*+.\/:-]*$/,el="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",nl=1,sl=40,fy=3,lS=3,sc=40,pS=10,dy=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],ly=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],tl=class{constructor(e,t,i,n){if(this.version=e,this.ecc=t,nc(this,"size"),nc(this,"mask"),nc(this,"modules",[]),nc(this,"types",[]),esl)throw new RangeError("Version value out of range");if(n<-1||n>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let s=Array.from({length:this.size},()=>!1);for(let f=0;f0));this.drawFunctionPatterns();let o=this.addEccAndInterleave(i);if(this.drawCodewords(o),n===-1){let f=1e9;for(let u=0;u<8;u++){this.applyMask(u),this.drawFormatBits(u);let c=this.getPenaltyScore();c=0&&e=0&&t>>9)*1335;let n=(t<<10|i)^21522;for(let s=0;s<=5;s++)this.setFunctionModule(8,s,Mi(n,s));this.setFunctionModule(8,7,Mi(n,6)),this.setFunctionModule(8,8,Mi(n,7)),this.setFunctionModule(7,8,Mi(n,8));for(let s=9;s<15;s++)this.setFunctionModule(14-s,8,Mi(n,s));for(let s=0;s<8;s++)this.setFunctionModule(this.size-1-s,8,Mi(n,s));for(let s=8;s<15;s++)this.setFunctionModule(8,this.size-15+s,Mi(n,s));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let i=0;i<12;i++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let i=0;i<18;i++){let n=Mi(t,i),s=this.size-11+i%3,o=Math.floor(i/3);this.setFunctionModule(s,o,n),this.setFunctionModule(o,s,n)}}drawFinderPattern(e,t){for(let i=-4;i<=4;i++)for(let n=-4;n<=4;n++){let s=Math.max(Math.abs(n),Math.abs(i)),o=e+n,f=t+i;o>=0&&o=0&&f{(S!==u-s||M>=f)&&v.push(I[S])});return v}drawCodewords(e){if(e.length!==Math.floor(rl(this.version)/8))throw new RangeError("Invalid argument");let t=0;for(let i=this.size-1;i>=1;i-=2){i===6&&(i=5);for(let n=0;n>>3],7-(t&7)),t++)}}}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(f,u),o||(e+=this.finderPenaltyCountPatterns(u)*sc),o=this.modules[s][c],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,u)*sc}for(let s=0;s5&&e++):(this.finderPenaltyAddHistory(f,u),o||(e+=this.finderPenaltyCountPatterns(u)*sc),o=this.modules[c][s],f=1);e+=this.finderPenaltyTerminateAndCount(o,f,u)*sc}for(let s=0;so+(f?1:0),t);let i=this.size*this.size,n=Math.ceil(Math.abs(t*20-i*10)/i)-1;return e+=n*pS,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,i=[6];for(let n=this.size-7;i.length0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(i&&e[0]>=t*4&&e[6]>=t?1:0)+(i&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,i){return e&&(this.finderPenaltyAddHistory(t,i),t=0),t+=this.size,this.finderPenaltyAddHistory(t,i),this.finderPenaltyCountPatterns(i)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}};function Ai(r,e,t){if(e<0||e>31||r>>>e)throw new RangeError("Value out of range");for(let i=e-1;i>=0;i--)t.push(r>>>i&1)}function Mi(r,e){return(r>>>e&1)!==0}var Go=class{constructor(e,t,i){if(this.mode=e,this.numChars=t,this.bitData=i,t<0)throw new RangeError("Invalid argument");this.bitData=i.slice()}getData(){return this.bitData.slice()}},gS=[1,10,12,14],bS=[2,9,11,13],vS=[4,8,16,16];function py(r,e){return r[Math.floor((e+7)/17)+1]}function gy(r){let e=[];for(let t of r)Ai(t,8,e);return new Go(vS,r.length,e)}function mS(r){if(!by(r))throw new RangeError("String contains non-numeric characters");let e=[];for(let t=0;t=1<sl)throw new RangeError("Version number out of range");let e=(16*r+128)*r+64;if(r>=2){let t=Math.floor(r/7)+2;e-=(25*t-10)*t-55,r>=7&&(e-=36)}return e}function oc(r,e){return Math.floor(rl(r)/8)-dy[e[0]][r]*ly[e[0]][r]}function ES(r){if(r<1||r>255)throw new RangeError("Degree out of range");let e=[];for(let i=0;i0);for(let i of r){let n=i^t.shift();t.push(0),e.forEach((s,o)=>t[o]^=il(s,n))}return t}function il(r,e){if(r>>>8||e>>>8)throw new RangeError("Byte out of range");let t=0;for(let i=7;i>=0;i--)t=t<<1^(t>>>7)*285,t^=(e>>>i&1)*r;return t}function IS(r,e,t=1,i=40,n=-1,s=!0){if(!(nl<=t&&t<=i&&i<=sl)||n<-1||n>7)throw new RangeError("Invalid value");let o,f;for(o=t;;o++){let v=oc(o,e)*8,S=_S(r,o);if(S<=v){f=S;break}if(o>=i)throw new RangeError("Data too long")}for(let v of[cy,hy,uy])s&&f<=oc(o,v)*8&&(e=v);let u=[];for(let v of r){Ai(v.mode[0],4,u),Ai(v.numChars,py(v.mode,o),u);for(let S of v.getData())u.push(S)}let c=oc(o,e)*8;Ai(0,Math.min(4,c-u.length),u),Ai(0,(8-u.length%8)%8,u);for(let v=236;u.length0);return u.forEach((v,S)=>b[S>>>3]|=v<<7-(S&7)),new tl(o,e,b,n)}function MS(r,e){let{ecc:t="L",boostEcc:i=!1,minVersion:n=1,maxVersion:s=40,maskPattern:o=-1,border:f=1}=e||{},u=typeof r=="string"?wS(r):Array.isArray(r)?[gy(r)]:void 0;if(!u)throw new Error(`uqr only supports encoding string and binary data, but got: ${typeof r}`);let c=IS(u,hS[t],n,s,o,i),b=AS({version:c.version,maskPattern:c.mask,size:c.size,data:c.modules,types:c.types},f);return e?.invert&&(b.data=b.data.map(v=>v.map(S=>!S))),e?.onEncoded?.(b),b}function AS(r,e=1){if(!e)return r;let{size:t}=r,i=t+e*2;r.size=i,r.data.forEach(s=>{for(let o=0;o!1)),r.data.push(Array.from({length:i},o=>!1));let n=Fn.Border;r.types.forEach(s=>{for(let o=0;on)),r.types.push(Array.from({length:i},o=>n));return r}function my(r,e={}){let t=MS(r,e),{pixelSize:i=10,whiteColor:n="white",blackColor:s="black"}=e,o=t.size*i,f=t.size*i,u=``,c=[];for(let b=0;b`,u+=``,u+="",u}var TS=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},DS=r=>{let e=`${ny}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},PS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},NS=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},ol={},CS=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",ol[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:ol[r.topic].signal}),t},ac={},OS=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=CS(r,e);return i.appendChild(s),ac[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:ac[r.topic].signal}),i},LS=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},FS=r=>{if(!r)return;document.getElementById(r)?.remove()},qS=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),US=r=>r?my(r):void 0,yy=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=US(e),o;if(s&&(o=TS(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),qS()&&n.appendChild(DS(e))),n&&t instanceof oi){let f=t.pairings,u=async b=>{try{b&&(await t.logout({topic:b}),FS(b))}catch(v){let S=Ho(v);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{ac[b].abort()}},c=async b=>{try{let{approval:v}=await t.connect({topic:b,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(b)?.after(LS()),await t.login({approval:v,token:i})}catch(v){let S=Ho(v);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let v of Object.values(ac))v?.abort();for(let v of Object.values(ol))v?.abort()}};if(f&&f.length>0){let b=PS();n.appendChild(b);let v=NS();b.appendChild(v);for(let S of f){let I=OS(S,u,c);b.appendChild(I)}}}return n};var wy=class{constructor({walletConnectV2ProjectId:e,walletConnectV2RelayAddresses:t,qrCodeContainer:i},n){this.WalletConnectV2Provider=oi;this.initMobileProvider=async e=>{if(!this.walletConnectV2ProjectId||!e.initOptions.chainType)return;let t={onClientLogin:()=>{},onClientLogout:()=>this.logout(e),onClientEvent:s=>{console.log("wc2 session event: ",s)}},i=Wd(this.walletConnectV2RelayAddresses),n=new oi(t,this.networkConfig[e.initOptions.chainType].shortId,i,this.walletConnectV2ProjectId,this.Message,this.Transaction,this.TransactionsConverter);try{return await n.init(),n}catch{console.warn("Can't initialize the Dapp Provider!");return}};this.loginWithMobile=async(e,t,i)=>{if(!this.qrCodeContainer)throw new Error("You haven't provided the QR code container DOM element id");let n=Wd(this.walletConnectV2RelayAddresses);if(!n||!e.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!this.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!e.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let s,o={onClientLogin:async()=>{if(e.dappProvider instanceof oi){let u=e.dappProvider.getAddress(),c=e.dappProvider.getSignature();if(this.ls.set("address",u),this.ls.set("loginMethod","mobile"),this.ls.set("expires",this.getNewLoginExpiresTimestamp()),await this.accountSync(e),c){this.ls.set("signature",c),this.ls.set("loginToken",t);let b=i.getToken(u,t,c);this.ls.set("accessToken",b),this.EventsStore.run("onLoginSuccess"),s?.replaceChildren()}}},onClientLogout:async()=>{e.dappProvider instanceof oi&&await this.logout(e)},onClientEvent:u=>{console.log("wc2 session event: ",u)}},f=new oi(o,this.networkConfig[e.initOptions.chainType].shortId,n,this.walletConnectV2ProjectId,this.Message,this.Transaction,this.TransactionsConverter);try{if(f){e.dappProvider=f,this.EventsStore.run("onQrPending"),await f.init();let{uri:u,approval:c}=await f.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),b=t?`${u}&token=${t}`:u;return this.qrCodeContainer&&b&&(s=await yy(this.qrCodeContainer,b,f,t),this.EventsStore.run("onQrLoaded")),await f.login({approval:c,token:t}),f}}catch(u){let c=Ho(u);console.warn(`Something went wrong trying to login the user: ${c}`),this.EventsStore.run("onLoginFailure",c)}};this.walletConnectV2ProjectId=e,this.walletConnectV2RelayAddresses=t,this.qrCodeContainer=i,this.networkConfig=n.networkConfig,this.Message=n.Message,this.Transaction=n.Transaction,this.TransactionsConverter=n.TransactionsConverter,this.ls=n.ls,this.logout=n.logout,this.getNewLoginExpiresTimestamp=n.getNewLoginExpiresTimestamp,this.accountSync=n.accountSync,this.EventsStore=n.EventsStore}};export{wy as MobileSigningProvider}; +/*! Bundled license information: + +tslib/tslib.es6.js: + (*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** *) + +js-sha3/src/sha3.js: + (** + * [js-sha3]{@link https://github.com/emn178/js-sha3} + * + * @version 0.8.0 + * @author Chen, Yi-Cyuan [emn178@gmail.com] + * @copyright Chen, Yi-Cyuan 2015-2018 + * @license MIT + *) +*/ diff --git a/dev-server.mjs b/dev-server.js similarity index 95% rename from dev-server.mjs rename to dev-server.js index bda379b..f33306a 100644 --- a/dev-server.mjs +++ b/dev-server.js @@ -3,7 +3,7 @@ import http from 'http'; const server = http.createServer((request, response) => { return handler(request, response, { - public: 'example', + public: 'demo-app', headers: [ { source: '**/*', diff --git a/esbuild.config.cjs b/esbuild.config.cjs deleted file mode 100644 index f86b40f..0000000 --- a/esbuild.config.cjs +++ /dev/null @@ -1,38 +0,0 @@ -/* eslint-disable @typescript-eslint/no-require-imports */ -const esbuild = require('esbuild'); - -const fs = require('fs'); - -const banner = `/*! - * Portions of this code are derived from MultiversX libraries. - * These portions are licensed under the MIT License. - * - * See the MultiversX repository for details: https://github.com/multiversx - * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE - */ -`; - -esbuild - .build({ - format: 'esm', - entryPoints: ['./src/elven.ts'], - bundle: true, - metafile: true, - minify: true, - outdir: 'build', - platform: 'browser', - banner: { js: banner }, - treeShaking: true, - // drop: ['console', 'debugger'], - }) - .then((result) => { - fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); - return result; - }) - .then((result) => { - return esbuild.analyzeMetafile(result.metafile); - }) - .then((result) => { - fs.writeFileSync('./build/meta.txt', result); - }) - .catch(() => process.exit(1)); diff --git a/eslint.config.js b/eslint.config.js new file mode 100644 index 0000000..0358aaa --- /dev/null +++ b/eslint.config.js @@ -0,0 +1,9 @@ +import eslintConfig from './configs/eslint-config/index.js'; + +export default [ + { + ignores: ['**/node_modules/**', '**/build/**', '**/.turbo/**'], + files: ['**/*.{js,jsx,ts,tsx}'], + }, + ...eslintConfig, +]; diff --git a/example/elven.js b/example/elven.js deleted file mode 100644 index 2f58e4c..0000000 --- a/example/elven.js +++ /dev/null @@ -1,67 +0,0 @@ -/*! - * Portions of this code are derived from MultiversX libraries. - * These portions are licensed under the MIT License. - * - * See the MultiversX repository for details: https://github.com/multiversx - * See the attached MIT licence for elven.js: https://github.com/elven-js/elven.js/blob/main/LICENSE - */ - -var K3=Object.create;var Ya=Object.defineProperty;var V3=Object.getOwnPropertyDescriptor;var $3=Object.getOwnPropertyNames;var H3=Object.getPrototypeOf,G3=Object.prototype.hasOwnProperty;var fp=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var W3=(r,e)=>()=>(r&&(e=r(r=0)),e);var J=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),qt=(r,e)=>{for(var t in e)Ya(r,t,{get:e[t],enumerable:!0})},Ja=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $3(e))!G3.call(r,n)&&n!==t&&Ya(r,n,{get:()=>e[n],enumerable:!(i=V3(e,n))||i.enumerable});return r},Ht=(r,e,t)=>(Ja(r,e,"default"),t&&Ja(t,e,"default")),Be=(r,e,t)=>(t=r!=null?K3(H3(r)):{},Ja(e||!r||!r.__esModule?Ya(t,"default",{value:r,enumerable:!0}):t,r)),Ao=r=>Ja(Ya({},"__esModule",{value:!0}),r);var Fn=J((vP,Hu)=>{"use strict";var ms=typeof Reflect=="object"?Reflect:null,Pp=ms&&typeof ms.apply=="function"?ms.apply:function(e,t,i){return Function.prototype.apply.call(e,t,i)},fc;ms&&typeof ms.ownKeys=="function"?fc=ms.ownKeys:Object.getOwnPropertySymbols?fc=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:fc=function(e){return Object.getOwnPropertyNames(e)};function t6(r){console&&console.warn&&console.warn(r)}var Np=Number.isNaN||function(e){return e!==e};function $e(){$e.init.call(this)}Hu.exports=$e;Hu.exports.once=s6;$e.EventEmitter=$e;$e.prototype._events=void 0;$e.prototype._eventsCount=0;$e.prototype._maxListeners=void 0;var Rp=10;function uc(r){if(typeof r!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r)}Object.defineProperty($e,"defaultMaxListeners",{enumerable:!0,get:function(){return Rp},set:function(r){if(typeof r!="number"||r<0||Np(r))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+r+".");Rp=r}});$e.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};$e.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Np(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Dp(r){return r._maxListeners===void 0?$e.defaultMaxListeners:r._maxListeners}$e.prototype.getMaxListeners=function(){return Dp(this)};$e.prototype.emit=function(e){for(var t=[],i=1;i0&&(o=t[0]),o instanceof Error)throw o;var a=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw a.context=o,a}var f=s[e];if(f===void 0)return!1;if(typeof f=="function")Pp(f,this,t);else for(var u=f.length,g=Up(f,u),i=0;i0&&o.length>n&&!o.warned){o.warned=!0;var a=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");a.name="MaxListenersExceededWarning",a.emitter=r,a.type=e,a.count=o.length,t6(a)}return r}$e.prototype.addListener=function(e,t){return Cp(this,e,t,!1)};$e.prototype.on=$e.prototype.addListener;$e.prototype.prependListener=function(e,t){return Cp(this,e,t,!0)};function r6(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Op(r,e,t){var i={fired:!1,wrapFn:void 0,target:r,type:e,listener:t},n=r6.bind(i);return n.listener=t,i.wrapFn=n,n}$e.prototype.once=function(e,t){return uc(t),this.on(e,Op(this,e,t)),this};$e.prototype.prependOnceListener=function(e,t){return uc(t),this.prependListener(e,Op(this,e,t)),this};$e.prototype.removeListener=function(e,t){var i,n,s,o,a;if(uc(t),n=this._events,n===void 0)return this;if(i=n[e],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,i.listener||t));else if(typeof i!="function"){for(s=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){a=i[o].listener,s=o;break}if(s<0)return this;s===0?i.shift():i6(i,s),i.length===1&&(n[e]=i[0]),n.removeListener!==void 0&&this.emit("removeListener",e,a||t)}return this};$e.prototype.off=$e.prototype.removeListener;$e.prototype.removeAllListeners=function(e){var t,i,n;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[e]),this;if(arguments.length===0){var s=Object.keys(i),o;for(n=0;n=0;n--)this.removeListener(e,t[n]);return this};function Lp(r,e,t){var i=r._events;if(i===void 0)return[];var n=i[e];return n===void 0?[]:typeof n=="function"?t?[n.listener||n]:[n]:t?n6(n):Up(n,n.length)}$e.prototype.listeners=function(e){return Lp(this,e,!0)};$e.prototype.rawListeners=function(e){return Lp(this,e,!1)};$e.listenerCount=function(r,e){return typeof r.listenerCount=="function"?r.listenerCount(e):Fp.call(r,e)};$e.prototype.listenerCount=Fp;function Fp(r){var e=this._events;if(e!==void 0){var t=e[r];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}$e.prototype.eventNames=function(){return this._eventsCount>0?fc(this._events):[]};function Up(r,e){for(var t=new Array(e),i=0;iWu,__asyncDelegator:()=>y6,__asyncGenerator:()=>v6,__asyncValues:()=>w6,__await:()=>Oo,__awaiter:()=>d6,__classPrivateFieldGet:()=>S6,__classPrivateFieldSet:()=>I6,__createBinding:()=>p6,__decorate:()=>f6,__exportStar:()=>g6,__extends:()=>a6,__generator:()=>l6,__importDefault:()=>E6,__importStar:()=>_6,__makeTemplateObject:()=>x6,__metadata:()=>h6,__param:()=>u6,__read:()=>Bp,__rest:()=>c6,__spread:()=>m6,__spreadArrays:()=>b6,__values:()=>Ju});function a6(r,e){Gu(r,e);function t(){this.constructor=r}r.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function c6(r,e){var t={};for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&e.indexOf(i)<0&&(t[i]=r[i]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(r);n=0;a--)(o=r[a])&&(s=(n<3?o(s):n>3?o(e,t,s):o(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function u6(r,e){return function(t,i){e(t,i,r)}}function h6(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}function d6(r,e,t,i){function n(s){return s instanceof t?s:new t(function(o){o(s)})}return new(t||(t=Promise))(function(s,o){function a(g){try{u(i.next(g))}catch(y){o(y)}}function f(g){try{u(i.throw(g))}catch(y){o(y)}}function u(g){g.done?s(g.value):n(g.value).then(a,f)}u((i=i.apply(r,e||[])).next())})}function l6(r,e){var t={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},i,n,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(u){return function(g){return f([u,g])}}function f(u){if(i)throw new TypeError("Generator is already executing.");for(;t;)try{if(i=1,n&&(s=u[0]&2?n.return:u[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,u[1])).done)return s;switch(n=0,s&&(u=[u[0]&2,s.value]),u[0]){case 0:case 1:s=u;break;case 4:return t.label++,{value:u[1],done:!1};case 5:t.label++,n=u[1],u=[0];continue;case 7:u=t.ops.pop(),t.trys.pop();continue;default:if(s=t.trys,!(s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){t=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]=r.length&&(r=void 0),{value:r&&r[i++],done:!r}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Bp(r,e){var t=typeof Symbol=="function"&&r[Symbol.iterator];if(!t)return r;var i=t.call(r),n,s=[],o;try{for(;(e===void 0||e-- >0)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(t=i.return)&&t.call(i)}finally{if(o)throw o.error}}return s}function m6(){for(var r=[],e=0;e1||a(S,I)})})}function a(S,I){try{f(i[S](I))}catch(A){y(s[0][3],A)}}function f(S){S.value instanceof Oo?Promise.resolve(S.value.v).then(u,g):y(s[0][2],S)}function u(S){a("next",S)}function g(S){a("throw",S)}function y(S,I){S(I),s.shift(),s.length&&a(s[0][0],s[0][1])}}function y6(r){var e,t;return e={},i("next"),i("throw",function(n){throw n}),i("return"),e[Symbol.iterator]=function(){return this},e;function i(n,s){e[n]=r[n]?function(o){return(t=!t)?{value:Oo(r[n](o)),done:n==="return"}:s?s(o):o}:s}}function w6(r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=r[Symbol.asyncIterator],t;return e?e.call(r):(r=typeof Ju=="function"?Ju(r):r[Symbol.iterator](),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=r[s]&&function(o){return new Promise(function(a,f){o=r[s](o),n(a,f,o.done,o.value)})}}function n(s,o,a,f){Promise.resolve(f).then(function(u){s({value:u,done:a})},o)}}function x6(r,e){return Object.defineProperty?Object.defineProperty(r,"raw",{value:e}):r.raw=e,r}function _6(r){if(r&&r.__esModule)return r;var e={};if(r!=null)for(var t in r)Object.hasOwnProperty.call(r,t)&&(e[t]=r[t]);return e.default=r,e}function E6(r){return r&&r.__esModule?r:{default:r}}function S6(r,e){if(!e.has(r))throw new TypeError("attempted to get private field on non-instance");return e.get(r)}function I6(r,e,t){if(!e.has(r))throw new TypeError("attempted to set private field on non-instance");return e.set(r,t),t}var Gu,Wu,vs=W3(()=>{Gu=function(r,e){return Gu=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,i){t.__proto__=i}||function(t,i){for(var n in i)i.hasOwnProperty(n)&&(t[n]=i[n])},Gu(r,e)};Wu=function(){return Wu=Object.assign||function(e){for(var t,i=1,n=arguments.length;i{"use strict";Object.defineProperty(hc,"__esModule",{value:!0});hc.delay=void 0;function A6(r){return new Promise(e=>{setTimeout(()=>{e(!0)},r)})}hc.delay=A6});var zp=J(ys=>{"use strict";Object.defineProperty(ys,"__esModule",{value:!0});ys.ONE_THOUSAND=ys.ONE_HUNDRED=void 0;ys.ONE_HUNDRED=100;ys.ONE_THOUSAND=1e3});var jp=J(Z=>{"use strict";Object.defineProperty(Z,"__esModule",{value:!0});Z.ONE_YEAR=Z.FOUR_WEEKS=Z.THREE_WEEKS=Z.TWO_WEEKS=Z.ONE_WEEK=Z.THIRTY_DAYS=Z.SEVEN_DAYS=Z.FIVE_DAYS=Z.THREE_DAYS=Z.ONE_DAY=Z.TWENTY_FOUR_HOURS=Z.TWELVE_HOURS=Z.SIX_HOURS=Z.THREE_HOURS=Z.ONE_HOUR=Z.SIXTY_MINUTES=Z.THIRTY_MINUTES=Z.TEN_MINUTES=Z.FIVE_MINUTES=Z.ONE_MINUTE=Z.SIXTY_SECONDS=Z.THIRTY_SECONDS=Z.TEN_SECONDS=Z.FIVE_SECONDS=Z.ONE_SECOND=void 0;Z.ONE_SECOND=1;Z.FIVE_SECONDS=5;Z.TEN_SECONDS=10;Z.THIRTY_SECONDS=30;Z.SIXTY_SECONDS=60;Z.ONE_MINUTE=Z.SIXTY_SECONDS;Z.FIVE_MINUTES=Z.ONE_MINUTE*5;Z.TEN_MINUTES=Z.ONE_MINUTE*10;Z.THIRTY_MINUTES=Z.ONE_MINUTE*30;Z.SIXTY_MINUTES=Z.ONE_MINUTE*60;Z.ONE_HOUR=Z.SIXTY_MINUTES;Z.THREE_HOURS=Z.ONE_HOUR*3;Z.SIX_HOURS=Z.ONE_HOUR*6;Z.TWELVE_HOURS=Z.ONE_HOUR*12;Z.TWENTY_FOUR_HOURS=Z.ONE_HOUR*24;Z.ONE_DAY=Z.TWENTY_FOUR_HOURS;Z.THREE_DAYS=Z.ONE_DAY*3;Z.FIVE_DAYS=Z.ONE_DAY*5;Z.SEVEN_DAYS=Z.ONE_DAY*7;Z.THIRTY_DAYS=Z.ONE_DAY*30;Z.ONE_WEEK=Z.SEVEN_DAYS;Z.TWO_WEEKS=Z.ONE_WEEK*2;Z.THREE_WEEKS=Z.ONE_WEEK*3;Z.FOUR_WEEKS=Z.ONE_WEEK*4;Z.ONE_YEAR=Z.ONE_DAY*365});var Yu=J(dc=>{"use strict";Object.defineProperty(dc,"__esModule",{value:!0});var Kp=(vs(),Ao(bs));Kp.__exportStar(zp(),dc);Kp.__exportStar(jp(),dc)});var $p=J(ws=>{"use strict";Object.defineProperty(ws,"__esModule",{value:!0});ws.fromMiliseconds=ws.toMiliseconds=void 0;var Vp=Yu();function M6(r){return r*Vp.ONE_THOUSAND}ws.toMiliseconds=M6;function T6(r){return Math.floor(r/Vp.ONE_THOUSAND)}ws.fromMiliseconds=T6});var Gp=J(lc=>{"use strict";Object.defineProperty(lc,"__esModule",{value:!0});var Hp=(vs(),Ao(bs));Hp.__exportStar(kp(),lc);Hp.__exportStar($p(),lc)});var Wp=J(Lo=>{"use strict";Object.defineProperty(Lo,"__esModule",{value:!0});Lo.Watch=void 0;var pc=class{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(typeof t.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(typeof t>"u")throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}};Lo.Watch=pc;Lo.default=pc});var Jp=J(gc=>{"use strict";Object.defineProperty(gc,"__esModule",{value:!0});gc.IWatch=void 0;var Xu=class{};gc.IWatch=Xu});var Yp=J(Qu=>{"use strict";Object.defineProperty(Qu,"__esModule",{value:!0});var P6=(vs(),Ao(bs));P6.__exportStar(Jp(),Qu)});var _s=J(xs=>{"use strict";Object.defineProperty(xs,"__esModule",{value:!0});var mc=(vs(),Ao(bs));mc.__exportStar(Gp(),xs);mc.__exportStar(Wp(),xs);mc.__exportStar(Yp(),xs);mc.__exportStar(Yu(),xs)});var dg=J(($P,hg)=>{"use strict";function X6(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}hg.exports=Q6;function Q6(r,e,t){var i=t&&t.stringify||X6,n=1;if(typeof r=="object"&&r!==null){var s=e.length+n;if(s===1)return r;var o=new Array(s);o[0]=i(r);for(var a=1;a-1?y:0,r.charCodeAt(I+1)){case 100:case 102:if(g>=f||e[g]==null)break;y=f||e[g]==null)break;y=f||e[g]===void 0)break;y",y=I+2,I++;break}u+=i(e[g]),y=I+2,I++;break;case 115:if(g>=f)break;y{"use strict";var lg=dg();mg.exports=Zr;var ko=c5().console||{},Z6={mapHttpRequest:xc,mapHttpResponse:xc,wrapRequestSerializer:ah,wrapResponseSerializer:ah,wrapErrorSerializer:ah,req:xc,res:xc,err:n5};function e5(r,e){return Array.isArray(r)?r.filter(function(i){return i!=="!stdSerializers.err"}):r===!0?Object.keys(e):!1}function Zr(r){r=r||{},r.browser=r.browser||{};let e=r.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");let t=r.browser.write||ko;r.browser.write&&(r.browser.asObject=!0);let i=r.serializers||{},n=e5(r.browser.serialize,i),s=r.browser.serialize;Array.isArray(r.browser.serialize)&&r.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);let o=["error","fatal","warn","info","debug","trace"];typeof t=="function"&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),r.enabled===!1&&(r.level="silent");let a=r.level||"info",f=Object.create(t);f.log||(f.log=zo),Object.defineProperty(f,"levelVal",{get:g}),Object.defineProperty(f,"level",{get:y,set:S});let u={transmit:e,serialize:n,asObject:r.browser.asObject,levels:o,timestamp:s5(r)};f.levels=Zr.levels,f.level=a,f.setMaxListeners=f.getMaxListeners=f.emit=f.addListener=f.on=f.prependListener=f.once=f.prependOnceListener=f.removeListener=f.removeAllListeners=f.listeners=f.listenerCount=f.eventNames=f.write=f.flush=zo,f.serializers=i,f._serialize=n,f._stdErrSerialize=s,f.child=I,e&&(f._logEvent=ch());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function y(){return this._level}function S(A){if(A!=="silent"&&!this.levels.values[A])throw Error("unknown level "+A);this._level=A,Es(u,f,"error","log"),Es(u,f,"fatal","error"),Es(u,f,"warn","error"),Es(u,f,"info","log"),Es(u,f,"debug","log"),Es(u,f,"trace","log")}function I(A,P){if(!A)throw new Error("missing bindings for child Pino");P=P||{},n&&A.serializers&&(P.serializers=A.serializers);let O=P.serializers;if(n&&O){var N=Object.assign({},i,O),U=r.browser.serialize===!0?Object.keys(N):n;delete A.serializers,_c([A],U,N,this._stdErrSerialize)}function k(B){this._childLevel=(B._childLevel|0)+1,this.error=Ss(B,A,"error"),this.fatal=Ss(B,A,"fatal"),this.warn=Ss(B,A,"warn"),this.info=Ss(B,A,"info"),this.debug=Ss(B,A,"debug"),this.trace=Ss(B,A,"trace"),N&&(this.serializers=N,this._serialize=U),e&&(this._logEvent=ch([].concat(B._logEvent.bindings,A)))}return k.prototype=this,new k(this)}return f}Zr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Zr.stdSerializers=Z6;Zr.stdTimeFunctions=Object.assign({},{nullTime:pg,epochTime:gg,unixTime:o5,isoTime:a5});function Es(r,e,t,i){let n=Object.getPrototypeOf(e);e[t]=e.levelVal>e.levels.values[t]?zo:n[t]?n[t]:ko[t]||ko[i]||zo,t5(r,e,t)}function t5(r,e,t){!r.transmit&&e[t]===zo||(e[t]=function(i){return function(){let s=r.timestamp(),o=new Array(arguments.length),a=Object.getPrototypeOf&&Object.getPrototypeOf(this)===ko?ko:this;for(var f=0;f-1&&s in t&&(r[n][s]=t[s](r[n][s]))}function Ss(r,e,t){return function(){let i=new Array(1+arguments.length);i[0]=e;for(var n=1;n{"use strict";Object.defineProperty(kc,"__esModule",{value:!0});kc.BrowserRandomSource=void 0;var xg=65536,ph=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let t=new Uint8Array(e);for(let i=0;i{"use strict";Object.defineProperty(gh,"__esModule",{value:!0});function w5(r){for(var e=0;e{});var Eg=J(zc=>{"use strict";Object.defineProperty(zc,"__esModule",{value:!0});zc.NodeRandomSource=void 0;var x5=cr(),bh=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof fp<"u"){let e=mh();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let t=this._crypto.randomBytes(e);if(t.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");let i=new Uint8Array(e);for(let n=0;n{"use strict";Object.defineProperty(jc,"__esModule",{value:!0});jc.SystemRandomSource=void 0;var _5=_g(),E5=Eg(),vh=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new _5.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new E5.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}};jc.SystemRandomSource=vh});var Ig=J(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});function S5(r,e){var t=r>>>16&65535,i=r&65535,n=e>>>16&65535,s=e&65535;return i*s+(t*s+i*n<<16>>>0)|0}Wt.mul=Math.imul||S5;function I5(r,e){return r+e|0}Wt.add=I5;function A5(r,e){return r-e|0}Wt.sub=A5;function M5(r,e){return r<>>32-e}Wt.rotl=M5;function T5(r,e){return r<<32-e|r>>>e}Wt.rotr=T5;function P5(r){return typeof r=="number"&&isFinite(r)&&Math.floor(r)===r}Wt.isInteger=Number.isInteger||P5;Wt.MAX_SAFE_INTEGER=9007199254740991;Wt.isSafeInteger=function(r){return Wt.isInteger(r)&&r>=-Wt.MAX_SAFE_INTEGER&&r<=Wt.MAX_SAFE_INTEGER}});var Is=J(Ue=>{"use strict";Object.defineProperty(Ue,"__esModule",{value:!0});var Ag=Ig();function R5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])<<16>>16}Ue.readInt16BE=R5;function N5(r,e){return e===void 0&&(e=0),(r[e+0]<<8|r[e+1])>>>0}Ue.readUint16BE=N5;function D5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])<<16>>16}Ue.readInt16LE=D5;function C5(r,e){return e===void 0&&(e=0),(r[e+1]<<8|r[e])>>>0}Ue.readUint16LE=C5;function Mg(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>8,e[t+1]=r>>>0,e}Ue.writeUint16BE=Mg;Ue.writeInt16BE=Mg;function Tg(r,e,t){return e===void 0&&(e=new Uint8Array(2)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e}Ue.writeUint16LE=Tg;Ue.writeInt16LE=Tg;function yh(r,e){return e===void 0&&(e=0),r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3]}Ue.readInt32BE=yh;function wh(r,e){return e===void 0&&(e=0),(r[e]<<24|r[e+1]<<16|r[e+2]<<8|r[e+3])>>>0}Ue.readUint32BE=wh;function xh(r,e){return e===void 0&&(e=0),r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e]}Ue.readInt32LE=xh;function _h(r,e){return e===void 0&&(e=0),(r[e+3]<<24|r[e+2]<<16|r[e+1]<<8|r[e])>>>0}Ue.readUint32LE=_h;function Kc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>24,e[t+1]=r>>>16,e[t+2]=r>>>8,e[t+3]=r>>>0,e}Ue.writeUint32BE=Kc;Ue.writeInt32BE=Kc;function Vc(r,e,t){return e===void 0&&(e=new Uint8Array(4)),t===void 0&&(t=0),e[t+0]=r>>>0,e[t+1]=r>>>8,e[t+2]=r>>>16,e[t+3]=r>>>24,e}Ue.writeUint32LE=Vc;Ue.writeInt32LE=Vc;function O5(r,e){e===void 0&&(e=0);var t=yh(r,e),i=yh(r,e+4);return t*4294967296+i-(i>>31)*4294967296}Ue.readInt64BE=O5;function L5(r,e){e===void 0&&(e=0);var t=wh(r,e),i=wh(r,e+4);return t*4294967296+i}Ue.readUint64BE=L5;function F5(r,e){e===void 0&&(e=0);var t=xh(r,e),i=xh(r,e+4);return i*4294967296+t-(t>>31)*4294967296}Ue.readInt64LE=F5;function U5(r,e){e===void 0&&(e=0);var t=_h(r,e),i=_h(r,e+4);return i*4294967296+t}Ue.readUint64LE=U5;function Pg(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Kc(r/4294967296>>>0,e,t),Kc(r>>>0,e,t+4),e}Ue.writeUint64BE=Pg;Ue.writeInt64BE=Pg;function Rg(r,e,t){return e===void 0&&(e=new Uint8Array(8)),t===void 0&&(t=0),Vc(r>>>0,e,t),Vc(r/4294967296>>>0,e,t+4),e}Ue.writeUint64LE=Rg;Ue.writeInt64LE=Rg;function q5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintBE: array is too short for the given bitLength");for(var i=0,n=1,s=r/8+t-1;s>=t;s--)i+=e[s]*n,n*=256;return i}Ue.readUintBE=q5;function B5(r,e,t){if(t===void 0&&(t=0),r%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(r/8>e.length-t)throw new Error("readUintLE: array is too short for the given bitLength");for(var i=0,n=1,s=t;s=i;s--)t[s]=e/n&255,n*=256;return t}Ue.writeUintBE=k5;function z5(r,e,t,i){if(t===void 0&&(t=new Uint8Array(r/8)),i===void 0&&(i=0),r%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!Ag.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var n=1,s=i;s{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Tt.randomStringForEntropy=Tt.randomString=Tt.randomUint32=Tt.randomBytes=Tt.defaultRandomSource=void 0;var Y5=Sg(),X5=Is(),Ng=cr();Tt.defaultRandomSource=new Y5.SystemRandomSource;function Eh(r,e=Tt.defaultRandomSource){return e.randomBytes(r)}Tt.randomBytes=Eh;function Q5(r=Tt.defaultRandomSource){let e=Eh(4,r),t=(0,X5.readUint32LE)(e);return(0,Ng.wipe)(e),t}Tt.randomUint32=Q5;var Dg="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function Cg(r,e=Dg,t=Tt.defaultRandomSource){if(e.length<2)throw new Error("randomString charset is too short");if(e.length>256)throw new Error("randomString charset is too long");let i="",n=e.length,s=256-256%n;for(;r>0;){let o=Eh(Math.ceil(r*256/s),t);for(let a=0;a0;a++){let f=o[a];f{"use strict";Object.defineProperty(Si,"__esModule",{value:!0});var Ms=Is(),As=cr();Si.DIGEST_LENGTH=64;Si.BLOCK_SIZE=128;var Lg=function(){function r(){this.digestLength=Si.DIGEST_LENGTH,this.blockSize=Si.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){As.wipe(this._buffer),As.wipe(this._tempHi),As.wipe(this._tempLo),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(Sh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=Sh(this._tempHi,this._tempLo,this._stateHi,this._stateLo,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%128<112?128:256;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._stateHi.set(e.stateHi),this._stateLo.set(e.stateLo),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){As.wipe(e.stateHi),As.wipe(e.stateLo),e.buffer&&As.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Si.SHA512=Lg;var Og=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function Sh(r,e,t,i,n,s,o){for(var a=t[0],f=t[1],u=t[2],g=t[3],y=t[4],S=t[5],I=t[6],A=t[7],P=i[0],O=i[1],N=i[2],U=i[3],k=i[4],B=i[5],j=i[6],V=i[7],L,C,W,R,l,w,p,c;o>=128;){for(var d=0;d<16;d++){var b=8*d+s;r[d]=Ms.readUint32BE(n,b),e[d]=Ms.readUint32BE(n,b+4)}for(var d=0;d<80;d++){var x=a,v=f,h=u,_=g,M=y,m=S,T=I,z=A,E=P,D=O,F=N,q=U,K=k,Y=B,H=j,$=V;if(L=A,C=V,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=(y>>>14|k<<18)^(y>>>18|k<<14)^(k>>>9|y<<23),C=(k>>>14|y<<18)^(k>>>18|y<<14)^(y>>>9|k<<23),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=y&S^~y&I,C=k&B^~k&j,l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=Og[d*2],C=Og[d*2+1],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=r[d%16],C=e[d%16],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,W=p&65535|c<<16,R=l&65535|w<<16,L=W,C=R,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=(a>>>28|P<<4)^(P>>>2|a<<30)^(P>>>7|a<<25),C=(P>>>28|a<<4)^(a>>>2|P<<30)^(a>>>7|P<<25),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,L=a&f^a&u^f&u,C=P&O^P&N^O&N,l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,z=p&65535|c<<16,$=l&65535|w<<16,L=_,C=q,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=W,C=R,l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,_=p&65535|c<<16,q=l&65535|w<<16,f=x,u=v,g=h,y=_,S=M,I=m,A=T,a=z,O=E,N=D,U=F,k=q,B=K,j=Y,V=H,P=$,d%16===15)for(var b=0;b<16;b++)L=r[b],C=e[b],l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=r[(b+9)%16],C=e[(b+9)%16],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,W=r[(b+1)%16],R=e[(b+1)%16],L=(W>>>1|R<<31)^(W>>>8|R<<24)^W>>>7,C=(R>>>1|W<<31)^(R>>>8|W<<24)^(R>>>7|W<<25),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,W=r[(b+14)%16],R=e[(b+14)%16],L=(W>>>19|R<<13)^(R>>>29|W<<3)^W>>>6,C=(R>>>19|W<<13)^(W>>>29|R<<3)^(R>>>6|W<<26),l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,r[b]=p&65535|c<<16,e[b]=l&65535|w<<16}L=a,C=P,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[0],C=i[0],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[0]=a=p&65535|c<<16,i[0]=P=l&65535|w<<16,L=f,C=O,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[1],C=i[1],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[1]=f=p&65535|c<<16,i[1]=O=l&65535|w<<16,L=u,C=N,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[2],C=i[2],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[2]=u=p&65535|c<<16,i[2]=N=l&65535|w<<16,L=g,C=U,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[3],C=i[3],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[3]=g=p&65535|c<<16,i[3]=U=l&65535|w<<16,L=y,C=k,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[4],C=i[4],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[4]=y=p&65535|c<<16,i[4]=k=l&65535|w<<16,L=S,C=B,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[5],C=i[5],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[5]=S=p&65535|c<<16,i[5]=B=l&65535|w<<16,L=I,C=j,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[6],C=i[6],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[6]=I=p&65535|c<<16,i[6]=j=l&65535|w<<16,L=A,C=V,l=C&65535,w=C>>>16,p=L&65535,c=L>>>16,L=t[7],C=i[7],l+=C&65535,w+=C>>>16,p+=L&65535,c+=L>>>16,w+=l>>>16,p+=w>>>16,c+=p>>>16,t[7]=A=p&65535|c<<16,i[7]=V=l&65535|w<<16,s+=128,o-=128}return s}function ex(r){var e=new Lg;e.update(r);var t=e.digest();return e.clean(),t}Si.hash=ex});var Yg=J(ze=>{"use strict";Object.defineProperty(ze,"__esModule",{value:!0});ze.convertSecretKeyToX25519=ze.convertPublicKeyToX25519=ze.verify=ze.sign=ze.extractPublicKeyFromSecretKey=ze.generateKeyPair=ze.generateKeyPairFromSeed=ze.SEED_LENGTH=ze.SECRET_KEY_LENGTH=ze.PUBLIC_KEY_LENGTH=ze.SIGNATURE_LENGTH=void 0;var tx=$o(),Ho=Fg(),zg=cr();ze.SIGNATURE_LENGTH=64;ze.PUBLIC_KEY_LENGTH=32;ze.SECRET_KEY_LENGTH=64;ze.SEED_LENGTH=32;function ie(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,jg(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function Kg(r,e){let t=0;for(let i=0;i<32;i++)t|=r[i]^e[i];return(1&t-1>>>8)-1}function Bg(r,e){let t=new Uint8Array(32),i=new Uint8Array(32);return Go(t,r),Go(i,e),Kg(t,i)}function Vg(r){let e=new Uint8Array(32);return Go(e,r),e[0]&1}function ox(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function Bn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function zn(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function He(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,P=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,C=0,W=0,R=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],M=t[1],m=t[2],T=t[3],z=t[4],E=t[5],D=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*M,a+=i*m,f+=i*T,u+=i*z,g+=i*E,y+=i*D,S+=i*F,I+=i*q,A+=i*K,P+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*M,f+=i*m,u+=i*T,g+=i*z,y+=i*E,S+=i*D,I+=i*F,A+=i*q,P+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*M,u+=i*m,g+=i*T,y+=i*z,S+=i*E,I+=i*D,A+=i*F,P+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*M,g+=i*m,y+=i*T,S+=i*z,I+=i*E,A+=i*D,P+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*M,y+=i*m,S+=i*T,I+=i*z,A+=i*E,P+=i*D,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,C+=i*X,i=e[5],g+=i*_,y+=i*M,S+=i*m,I+=i*T,A+=i*z,P+=i*E,O+=i*D,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,C+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*M,I+=i*m,A+=i*T,P+=i*z,O+=i*E,N+=i*D,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,C+=i*ee,W+=i*G,R+=i*X,i=e[7],S+=i*_,I+=i*M,A+=i*m,P+=i*T,O+=i*z,N+=i*E,U+=i*D,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,C+=i*$,W+=i*ee,R+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*M,P+=i*m,O+=i*T,N+=i*z,U+=i*E,k+=i*D,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,C+=i*H,W+=i*$,R+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,P+=i*M,O+=i*m,N+=i*T,U+=i*z,k+=i*E,B+=i*D,j+=i*F,V+=i*q,L+=i*K,C+=i*Y,W+=i*H,R+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],P+=i*_,O+=i*M,N+=i*m,U+=i*T,k+=i*z,B+=i*E,j+=i*D,V+=i*F,L+=i*q,C+=i*K,W+=i*Y,R+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*M,U+=i*m,k+=i*T,B+=i*z,j+=i*E,V+=i*D,L+=i*F,C+=i*q,W+=i*K,R+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*M,k+=i*m,B+=i*T,j+=i*z,V+=i*E,L+=i*D,C+=i*F,W+=i*q,R+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*M,B+=i*m,j+=i*T,V+=i*z,L+=i*E,C+=i*D,W+=i*F,R+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*M,j+=i*m,V+=i*T,L+=i*z,C+=i*E,W+=i*D,R+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*M,V+=i*m,L+=i*T,C+=i*z,W+=i*E,R+=i*D,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*C,u+=38*W,g+=38*R,y+=38*l,S+=38*w,I+=38*p,A+=38*c,P+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=P,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function kn(r,e){He(r,e,e)}function $g(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=253;i>=0;i--)kn(t,t),i!==2&&i!==4&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function ax(r,e){let t=ie(),i;for(i=0;i<16;i++)t[i]=e[i];for(i=250;i>=0;i--)kn(t,t),i!==1&&He(t,t,e);for(i=0;i<16;i++)r[i]=t[i]}function Th(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie(),u=ie(),g=ie();zn(t,r[1],r[0]),zn(g,e[1],e[0]),He(t,t,g),Bn(i,r[0],r[1]),Bn(g,e[0],e[1]),He(i,i,g),He(n,r[3],e[3]),He(n,n,nx),He(s,r[2],e[2]),Bn(s,s,s),zn(o,i,t),zn(a,s,n),Bn(f,s,n),Bn(u,i,t),He(r[0],o,a),He(r[1],u,f),He(r[2],f,a),He(r[3],o,u)}function kg(r,e,t){for(let i=0;i<4;i++)jg(r[i],e[i],t)}function Rh(r,e){let t=ie(),i=ie(),n=ie();$g(n,e[2]),He(t,e[0],n),He(i,e[1],n),Go(r,i),r[31]^=Vg(t)<<7}function Hg(r,e,t){$i(r[0],Mh),$i(r[1],Ts),$i(r[2],Ts),$i(r[3],Mh);for(let i=255;i>=0;--i){let n=t[i/8|0]>>(i&7)&1;kg(r,e,n),Th(e,r),Th(r,r),kg(r,e,n)}}function Nh(r,e){let t=[ie(),ie(),ie(),ie()];$i(t[0],Ug),$i(t[1],qg),$i(t[2],Ts),He(t[3],Ug,qg),Hg(r,t,e)}function Gg(r){if(r.length!==ze.SEED_LENGTH)throw new Error(`ed25519: seed must be ${ze.SEED_LENGTH} bytes`);let e=(0,Ho.hash)(r);e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(32),i=[ie(),ie(),ie(),ie()];Nh(i,e),Rh(t,i);let n=new Uint8Array(64);return n.set(r),n.set(t,32),{publicKey:t,secretKey:n}}ze.generateKeyPairFromSeed=Gg;function cx(r){let e=(0,tx.randomBytes)(32,r),t=Gg(e);return(0,zg.wipe)(e),t}ze.generateKeyPair=cx;function fx(r){if(r.length!==ze.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${ze.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(r.subarray(32))}ze.extractPublicKeyFromSecretKey=fx;var Ah=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Wg(r,e){let t,i,n,s;for(i=63;i>=32;--i){for(t=0,n=i-32,s=i-12;n>4)*Ah[n],t=e[n]>>8,e[n]&=255;for(n=0;n<32;n++)e[n]-=t*Ah[n];for(i=0;i<32;i++)e[i+1]+=e[i]>>8,r[i]=e[i]&255}function Ph(r){let e=new Float64Array(64);for(let t=0;t<64;t++)e[t]=r[t];for(let t=0;t<64;t++)r[t]=0;Wg(r,e)}function ux(r,e){let t=new Float64Array(64),i=[ie(),ie(),ie(),ie()],n=(0,Ho.hash)(r.subarray(0,32));n[0]&=248,n[31]&=127,n[31]|=64;let s=new Uint8Array(64);s.set(n.subarray(32),32);let o=new Ho.SHA512;o.update(s.subarray(32)),o.update(e);let a=o.digest();o.clean(),Ph(a),Nh(i,a),Rh(s,i),o.reset(),o.update(s.subarray(0,32)),o.update(r.subarray(32)),o.update(e);let f=o.digest();Ph(f);for(let u=0;u<32;u++)t[u]=a[u];for(let u=0;u<32;u++)for(let g=0;g<32;g++)t[u+g]+=f[u]*n[g];return Wg(s.subarray(32),t),s}ze.sign=ux;function Jg(r,e){let t=ie(),i=ie(),n=ie(),s=ie(),o=ie(),a=ie(),f=ie();return $i(r[2],Ts),ox(r[1],e),kn(n,r[1]),He(s,n,ix),zn(n,n,r[2]),Bn(s,r[2],s),kn(o,s),kn(a,o),He(f,a,o),He(t,f,n),He(t,t,s),ax(t,t),He(t,t,n),He(t,t,s),He(t,t,s),He(r[0],t,s),kn(i,r[0]),He(i,i,s),Bg(i,n)&&He(r[0],r[0],sx),kn(i,r[0]),He(i,i,s),Bg(i,n)?-1:(Vg(r[0])===e[31]>>7&&zn(r[0],Mh,r[0]),He(r[3],r[0],r[1]),0)}function hx(r,e,t){let i=new Uint8Array(32),n=[ie(),ie(),ie(),ie()],s=[ie(),ie(),ie(),ie()];if(t.length!==ze.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${ze.SIGNATURE_LENGTH} bytes`);if(Jg(s,r))return!1;let o=new Ho.SHA512;o.update(t.subarray(0,32)),o.update(r),o.update(e);let a=o.digest();return Ph(a),Hg(n,s,a),Nh(s,t.subarray(32)),Th(n,s),Rh(i,n),!Kg(t,i)}ze.verify=hx;function dx(r){let e=[ie(),ie(),ie(),ie()];if(Jg(e,r))throw new Error("Ed25519: invalid public key");let t=ie(),i=ie(),n=e[1];Bn(t,Ts,n),zn(i,Ts,n),$g(i,i),He(t,t,i);let s=new Uint8Array(32);return Go(s,t),s}ze.convertPublicKeyToX25519=dx;function lx(r){let e=(0,Ho.hash)(r.subarray(0,32));e[0]&=248,e[31]&=127,e[31]|=64;let t=new Uint8Array(e.subarray(0,32));return(0,zg.wipe)(e),t}ze.convertSecretKeyToX25519=lx});var Qc=J(Je=>{"use strict";Object.defineProperty(Je,"__esModule",{value:!0});Je.getLocalStorage=Je.getLocalStorageOrThrow=Je.getCrypto=Je.getCryptoOrThrow=Je.getLocation=Je.getLocationOrThrow=Je.getNavigator=Je.getNavigatorOrThrow=Je.getDocument=Je.getDocumentOrThrow=Je.getFromWindowOrThrow=Je.getFromWindow=void 0;function Vn(r){let e;return typeof window<"u"&&typeof window[r]<"u"&&(e=window[r]),e}Je.getFromWindow=Vn;function Ls(r){let e=Vn(r);if(!e)throw new Error(`${r} is not defined in Window`);return e}Je.getFromWindowOrThrow=Ls;function k4(){return Ls("document")}Je.getDocumentOrThrow=k4;function z4(){return Vn("document")}Je.getDocument=z4;function j4(){return Ls("navigator")}Je.getNavigatorOrThrow=j4;function K4(){return Vn("navigator")}Je.getNavigator=K4;function V4(){return Ls("location")}Je.getLocationOrThrow=V4;function $4(){return Vn("location")}Je.getLocation=$4;function H4(){return Ls("crypto")}Je.getCryptoOrThrow=H4;function G4(){return Vn("crypto")}Je.getCrypto=G4;function W4(){return Ls("localStorage")}Je.getLocalStorageOrThrow=W4;function J4(){return Vn("localStorage")}Je.getLocalStorage=J4});var F1=J(Zc=>{"use strict";Object.defineProperty(Zc,"__esModule",{value:!0});Zc.getWindowMetadata=void 0;var L1=Qc();function Y4(){let r,e;try{r=L1.getDocumentOrThrow(),e=L1.getLocationOrThrow()}catch{return null}function t(){let y=r.getElementsByTagName("link"),S=[];for(let I=0;I-1){let O=A.getAttribute("href");if(O)if(O.toLowerCase().indexOf("https:")===-1&&O.toLowerCase().indexOf("http:")===-1&&O.indexOf("//")!==0){let N=e.protocol+"//"+e.host;if(O.indexOf("/")===0)N+=O;else{let U=e.pathname.split("/");U.pop();let k=U.join("/");N+=k+"/"+O}S.push(N)}else if(O.indexOf("//")===0){let N=e.protocol+O;S.push(N)}else S.push(O)}}return S}function i(...y){let S=r.getElementsByTagName("meta");for(let I=0;IA.getAttribute(O)).filter(O=>O?y.includes(O):!1);if(P.length&&P){let O=A.getAttribute("content");if(O)return O}}return""}function n(){let y=i("name","og:site_name","og:title","twitter:title");return y||(y=r.title),y}function s(){return i("description","og:description","twitter:description","keywords")}let o=n(),a=s(),f=e.origin,u=t();return{description:a,url:f,icons:u,name:o}}Zc.getWindowMetadata=Y4});var q1=J((bN,U1)=>{"use strict";U1.exports=r=>encodeURIComponent(r).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var K1=J((vN,j1)=>{"use strict";var z1="%[a-f0-9]{2}",B1=new RegExp("("+z1+")|([^%]+?)","gi"),k1=new RegExp("("+z1+")+","gi");function id(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;var t=r.slice(0,e),i=r.slice(e);return Array.prototype.concat.call([],id(t),id(i))}function X4(r){try{return decodeURIComponent(r)}catch{for(var e=r.match(B1)||[],t=1;t{"use strict";V1.exports=(r,e)=>{if(!(typeof r=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[r];let t=r.indexOf(e);return t===-1?[r]:[r.slice(0,t),r.slice(t+e.length)]}});var G1=J((wN,H1)=>{"use strict";H1.exports=function(r,e){for(var t={},i=Object.keys(r),n=Array.isArray(e),s=0;s{"use strict";var Z4=q1(),e8=K1(),J1=$1(),t8=G1(),r8=r=>r==null,nd=Symbol("encodeFragmentIdentifier");function i8(r){switch(r.arrayFormat){case"index":return e=>(t,i)=>{let n=t.length;return i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[",n,"]"].join("")]:[...t,[ct(e,r),"[",ct(n,r),"]=",ct(i,r)].join("")]};case"bracket":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),"[]"].join("")]:[...t,[ct(e,r),"[]=",ct(i,r)].join("")];case"colon-list-separator":return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,[ct(e,r),":list="].join("")]:[...t,[ct(e,r),":list=",ct(i,r)].join("")];case"comma":case"separator":case"bracket-separator":{let e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(i,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?i:(n=n===null?"":n,i.length===0?[[ct(t,r),e,ct(n,r)].join("")]:[[i,ct(n,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,i)=>i===void 0||r.skipNull&&i===null||r.skipEmptyString&&i===""?t:i===null?[...t,ct(e,r)]:[...t,[ct(e,r),"=",ct(i,r)].join("")]}}function n8(r){let e;switch(r.arrayFormat){case"index":return(t,i,n)=>{if(e=/\[(\d*)\]$/.exec(t),t=t.replace(/\[\d*\]$/,""),!e){n[t]=i;return}n[t]===void 0&&(n[t]={}),n[t][e[1]]=i};case"bracket":return(t,i,n)=>{if(e=/(\[\])$/.exec(t),t=t.replace(/\[\]$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"colon-list-separator":return(t,i,n)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){n[t]=i;return}if(n[t]===void 0){n[t]=[i];return}n[t]=[].concat(n[t],i)};case"comma":case"separator":return(t,i,n)=>{let s=typeof i=="string"&&i.includes(r.arrayFormatSeparator),o=typeof i=="string"&&!s&&Ai(i,r).includes(r.arrayFormatSeparator);i=o?Ai(i,r):i;let a=s||o?i.split(r.arrayFormatSeparator).map(f=>Ai(f,r)):i===null?i:Ai(i,r);n[t]=a};case"bracket-separator":return(t,i,n)=>{let s=/(\[\])$/.test(t);if(t=t.replace(/\[\]$/,""),!s){n[t]=i&&Ai(i,r);return}let o=i===null?[]:i.split(r.arrayFormatSeparator).map(a=>Ai(a,r));if(n[t]===void 0){n[t]=o;return}n[t]=[].concat(n[t],o)};default:return(t,i,n)=>{if(n[t]===void 0){n[t]=i;return}n[t]=[].concat(n[t],i)}}}function Y1(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function ct(r,e){return e.encode?e.strict?Z4(r):encodeURIComponent(r):r}function Ai(r,e){return e.decode?e8(r):r}function X1(r){return Array.isArray(r)?r.sort():typeof r=="object"?X1(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function Q1(r){let e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function s8(r){let e="",t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function Z1(r){r=Q1(r);let e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function W1(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function em(r,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),Y1(e.arrayFormatSeparator);let t=n8(e),i=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return i;for(let n of r.split("&")){if(n==="")continue;let[s,o]=J1(e.decode?n.replace(/\+/g," "):n,"=");o=o===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?o:Ai(o,e),t(Ai(s,e),o,i)}for(let n of Object.keys(i)){let s=i[n];if(typeof s=="object"&&s!==null)for(let o of Object.keys(s))s[o]=W1(s[o],e);else i[n]=W1(s,e)}return e.sort===!1?i:(e.sort===!0?Object.keys(i).sort():Object.keys(i).sort(e.sort)).reduce((n,s)=>{let o=i[s];return o&&typeof o=="object"&&!Array.isArray(o)?n[s]=X1(o):n[s]=o,n},Object.create(null))}zt.extract=Z1;zt.parse=em;zt.stringify=(r,e)=>{if(!r)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),Y1(e.arrayFormatSeparator);let t=o=>e.skipNull&&r8(r[o])||e.skipEmptyString&&r[o]==="",i=i8(e),n={};for(let o of Object.keys(r))t(o)||(n[o]=r[o]);let s=Object.keys(n);return e.sort!==!1&&s.sort(e.sort),s.map(o=>{let a=r[o];return a===void 0?"":a===null?ct(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?ct(o,e)+"[]":a.reduce(i(o),[]).join("&"):ct(o,e)+"="+ct(a,e)}).filter(o=>o.length>0).join("&")};zt.parseUrl=(r,e)=>{e=Object.assign({decode:!0},e);let[t,i]=J1(r,"#");return Object.assign({url:t.split("?")[0]||"",query:em(Z1(r),e)},e&&e.parseFragmentIdentifier&&i?{fragmentIdentifier:Ai(i,e)}:{})};zt.stringifyUrl=(r,e)=>{e=Object.assign({encode:!0,strict:!0,[nd]:!0},e);let t=Q1(r.url).split("?")[0]||"",i=zt.extract(r.url),n=zt.parse(i,{sort:!1}),s=Object.assign(n,r.query),o=zt.stringify(s,e);o&&(o=`?${o}`);let a=s8(r.url);return r.fragmentIdentifier&&(a=`#${e[nd]?ct(r.fragmentIdentifier,e):r.fragmentIdentifier}`),`${t}${o}${a}`};zt.pick=(r,e,t)=>{t=Object.assign({parseFragmentIdentifier:!0,[nd]:!1},t);let{url:i,query:n,fragmentIdentifier:s}=zt.parseUrl(r,t);return zt.stringifyUrl({url:i,query:t8(n,e),fragmentIdentifier:s},t)};zt.exclude=(r,e,t)=>{let i=Array.isArray(e)?n=>!e.includes(n):(n,s)=>!e(n,s);return zt.pick(r,i,t)}});var rm=J((_N,ef)=>{(function(){"use strict";var r="input is invalid type",e="finalize already called",t=typeof window=="object",i=t?window:{};i.JS_SHA3_NO_WINDOW&&(t=!1);var n=!t&&typeof self=="object",s=!i.JS_SHA3_NO_NODE_JS&&typeof process=="object"&&process.versions&&process.versions.node;s?i=global:n&&(i=self);var o=!i.JS_SHA3_NO_COMMON_JS&&typeof ef=="object"&&ef.exports,a=typeof define=="function"&&define.amd,f=!i.JS_SHA3_NO_ARRAY_BUFFER&&typeof ArrayBuffer<"u",u="0123456789abcdef".split(""),g=[31,7936,2031616,520093696],y=[4,1024,262144,67108864],S=[1,256,65536,16777216],I=[6,1536,393216,100663296],A=[0,8,16,24],P=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648],O=[224,256,384,512],N=[128,256],U=["hex","buffer","arrayBuffer","array","digest"],k={128:168,256:136};(i.JS_SHA3_NO_NODE_JS||!Array.isArray)&&(Array.isArray=function(E){return Object.prototype.toString.call(E)==="[object Array]"}),f&&(i.JS_SHA3_NO_ARRAY_BUFFER_IS_VIEW||!ArrayBuffer.isView)&&(ArrayBuffer.isView=function(E){return typeof E=="object"&&E.buffer&&E.buffer.constructor===ArrayBuffer});for(var B=function(E,D,F){return function(q){return new m(E,D,E).update(q)[F]()}},j=function(E,D,F){return function(q,K){return new m(E,D,K).update(q)[F]()}},V=function(E,D,F){return function(q,K,Y,H){return c["cshake"+E].update(q,K,Y,H)[F]()}},L=function(E,D,F){return function(q,K,Y,H){return c["kmac"+E].update(q,K,Y,H)[F]()}},C=function(E,D,F,q){for(var K=0;K>5,this.byteCount=this.blockCount<<2,this.outputBlocks=F>>5,this.extraBytes=(F&31)>>3;for(var q=0;q<50;++q)this.s[q]=0}m.prototype.update=function(E){if(this.finalized)throw new Error(e);var D,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);D=!0}for(var q=this.blocks,K=this.byteCount,Y=E.length,H=this.blockCount,$=0,ee=this.s,G,X;$>2]|=E[$]<>2]|=X<>2]|=(192|X>>6)<>2]|=(128|X&63)<=57344?(q[G>>2]|=(224|X>>12)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<>2]|=(240|X>>18)<>2]|=(128|X>>12&63)<>2]|=(128|X>>6&63)<>2]|=(128|X&63)<=K){for(this.start=G-K,this.block=q[H],G=0;G>8,F=E&255;F>0;)K.unshift(F),E=E>>8,F=E&255,++q;return D?K.push(q):K.unshift(q),this.update(K),K.length},m.prototype.encodeString=function(E){var D,F=typeof E;if(F!=="string"){if(F==="object"){if(E===null)throw new Error(r);if(f&&E.constructor===ArrayBuffer)E=new Uint8Array(E);else if(!Array.isArray(E)&&(!f||!ArrayBuffer.isView(E)))throw new Error(r)}else throw new Error(r);D=!0}var q=0,K=E.length;if(D)q=K;else for(var Y=0;Y=57344?q+=3:(H=65536+((H&1023)<<10|E.charCodeAt(++Y)&1023),q+=4)}return q+=this.encode(q*8),this.update(E),q},m.prototype.bytepad=function(E,D){for(var F=this.encode(D),q=0;q>2]|=this.padding[D&3],this.lastByteIndex===this.byteCount)for(E[0]=E[F],D=1;D>4&15]+u[$&15]+u[$>>12&15]+u[$>>8&15]+u[$>>20&15]+u[$>>16&15]+u[$>>28&15]+u[$>>24&15];Y%E===0&&(z(D),K=0)}return q&&($=D[K],H+=u[$>>4&15]+u[$&15],q>1&&(H+=u[$>>12&15]+u[$>>8&15]),q>2&&(H+=u[$>>20&15]+u[$>>16&15])),H},m.prototype.arrayBuffer=function(){this.finalize();var E=this.blockCount,D=this.s,F=this.outputBlocks,q=this.extraBytes,K=0,Y=0,H=this.outputBits>>3,$;q?$=new ArrayBuffer(F+1<<2):$=new ArrayBuffer(H);for(var ee=new Uint32Array($);Y>8&255,H[$+2]=ee>>16&255,H[$+3]=ee>>24&255;Y%E===0&&z(D)}return q&&($=Y<<2,ee=D[K],H[$]=ee&255,q>1&&(H[$+1]=ee>>8&255),q>2&&(H[$+2]=ee>>16&255)),H};function T(E,D,F){m.call(this,E,D,F)}T.prototype=new m,T.prototype.finalize=function(){return this.encode(this.outputBits,!0),m.prototype.finalize.call(this)};var z=function(E){var D,F,q,K,Y,H,$,ee,G,X,Ur,se,oe,qr,ae,ce,Br,fe,ue,kr,he,de,zr,le,pe,jr,ge,me,Kr,be,ve,Vr,ye,we,$r,xe,_e,Hr,Ee,Se,Gr,Ie,Ae,Wr,Me,Te,Jr,Pe,Re,Yr,Ne,De,Xr,Ce,Oe,vr,Ke,Ve,tr,rr,ir,nr,sr;for(q=0;q<48;q+=2)K=E[0]^E[10]^E[20]^E[30]^E[40],Y=E[1]^E[11]^E[21]^E[31]^E[41],H=E[2]^E[12]^E[22]^E[32]^E[42],$=E[3]^E[13]^E[23]^E[33]^E[43],ee=E[4]^E[14]^E[24]^E[34]^E[44],G=E[5]^E[15]^E[25]^E[35]^E[45],X=E[6]^E[16]^E[26]^E[36]^E[46],Ur=E[7]^E[17]^E[27]^E[37]^E[47],se=E[8]^E[18]^E[28]^E[38]^E[48],oe=E[9]^E[19]^E[29]^E[39]^E[49],D=se^(H<<1|$>>>31),F=oe^($<<1|H>>>31),E[0]^=D,E[1]^=F,E[10]^=D,E[11]^=F,E[20]^=D,E[21]^=F,E[30]^=D,E[31]^=F,E[40]^=D,E[41]^=F,D=K^(ee<<1|G>>>31),F=Y^(G<<1|ee>>>31),E[2]^=D,E[3]^=F,E[12]^=D,E[13]^=F,E[22]^=D,E[23]^=F,E[32]^=D,E[33]^=F,E[42]^=D,E[43]^=F,D=H^(X<<1|Ur>>>31),F=$^(Ur<<1|X>>>31),E[4]^=D,E[5]^=F,E[14]^=D,E[15]^=F,E[24]^=D,E[25]^=F,E[34]^=D,E[35]^=F,E[44]^=D,E[45]^=F,D=ee^(se<<1|oe>>>31),F=G^(oe<<1|se>>>31),E[6]^=D,E[7]^=F,E[16]^=D,E[17]^=F,E[26]^=D,E[27]^=F,E[36]^=D,E[37]^=F,E[46]^=D,E[47]^=F,D=X^(K<<1|Y>>>31),F=Ur^(Y<<1|K>>>31),E[8]^=D,E[9]^=F,E[18]^=D,E[19]^=F,E[28]^=D,E[29]^=F,E[38]^=D,E[39]^=F,E[48]^=D,E[49]^=F,qr=E[0],ae=E[1],Te=E[11]<<4|E[10]>>>28,Jr=E[10]<<4|E[11]>>>28,me=E[20]<<3|E[21]>>>29,Kr=E[21]<<3|E[20]>>>29,rr=E[31]<<9|E[30]>>>23,ir=E[30]<<9|E[31]>>>23,Ie=E[40]<<18|E[41]>>>14,Ae=E[41]<<18|E[40]>>>14,we=E[2]<<1|E[3]>>>31,$r=E[3]<<1|E[2]>>>31,ce=E[13]<<12|E[12]>>>20,Br=E[12]<<12|E[13]>>>20,Pe=E[22]<<10|E[23]>>>22,Re=E[23]<<10|E[22]>>>22,be=E[33]<<13|E[32]>>>19,ve=E[32]<<13|E[33]>>>19,nr=E[42]<<2|E[43]>>>30,sr=E[43]<<2|E[42]>>>30,Ce=E[5]<<30|E[4]>>>2,Oe=E[4]<<30|E[5]>>>2,xe=E[14]<<6|E[15]>>>26,_e=E[15]<<6|E[14]>>>26,fe=E[25]<<11|E[24]>>>21,ue=E[24]<<11|E[25]>>>21,Yr=E[34]<<15|E[35]>>>17,Ne=E[35]<<15|E[34]>>>17,Vr=E[45]<<29|E[44]>>>3,ye=E[44]<<29|E[45]>>>3,le=E[6]<<28|E[7]>>>4,pe=E[7]<<28|E[6]>>>4,vr=E[17]<<23|E[16]>>>9,Ke=E[16]<<23|E[17]>>>9,Hr=E[26]<<25|E[27]>>>7,Ee=E[27]<<25|E[26]>>>7,kr=E[36]<<21|E[37]>>>11,he=E[37]<<21|E[36]>>>11,De=E[47]<<24|E[46]>>>8,Xr=E[46]<<24|E[47]>>>8,Wr=E[8]<<27|E[9]>>>5,Me=E[9]<<27|E[8]>>>5,jr=E[18]<<20|E[19]>>>12,ge=E[19]<<20|E[18]>>>12,Ve=E[29]<<7|E[28]>>>25,tr=E[28]<<7|E[29]>>>25,Se=E[38]<<8|E[39]>>>24,Gr=E[39]<<8|E[38]>>>24,de=E[48]<<14|E[49]>>>18,zr=E[49]<<14|E[48]>>>18,E[0]=qr^~ce&fe,E[1]=ae^~Br&ue,E[10]=le^~jr&me,E[11]=pe^~ge&Kr,E[20]=we^~xe&Hr,E[21]=$r^~_e&Ee,E[30]=Wr^~Te&Pe,E[31]=Me^~Jr&Re,E[40]=Ce^~vr&Ve,E[41]=Oe^~Ke&tr,E[2]=ce^~fe&kr,E[3]=Br^~ue&he,E[12]=jr^~me&be,E[13]=ge^~Kr&ve,E[22]=xe^~Hr&Se,E[23]=_e^~Ee&Gr,E[32]=Te^~Pe&Yr,E[33]=Jr^~Re&Ne,E[42]=vr^~Ve&rr,E[43]=Ke^~tr&ir,E[4]=fe^~kr&de,E[5]=ue^~he&zr,E[14]=me^~be&Vr,E[15]=Kr^~ve&ye,E[24]=Hr^~Se&Ie,E[25]=Ee^~Gr&Ae,E[34]=Pe^~Yr&De,E[35]=Re^~Ne&Xr,E[44]=Ve^~rr&nr,E[45]=tr^~ir&sr,E[6]=kr^~de&qr,E[7]=he^~zr&ae,E[16]=be^~Vr&le,E[17]=ve^~ye&pe,E[26]=Se^~Ie&we,E[27]=Gr^~Ae&$r,E[36]=Yr^~De&Wr,E[37]=Ne^~Xr&Me,E[46]=rr^~nr&Ce,E[47]=ir^~sr&Oe,E[8]=de^~qr&ce,E[9]=zr^~ae&Br,E[18]=Vr^~le&jr,E[19]=ye^~pe&ge,E[28]=Ie^~we&xe,E[29]=Ae^~$r&_e,E[38]=De^~Wr&Te,E[39]=Xr^~Me&Jr,E[48]=nr^~Ce&vr,E[49]=sr^~Oe&Ke,E[0]^=P[q],E[1]^=P[q+1]};if(o)ef.exports=c;else{for(b=0;b{});var dd=J((pm,hd)=>{(function(r,e){"use strict";function t(p,c){if(!p)throw new Error(c||"Assertion failed")}function i(p,c){p.super_=c;var d=function(){};d.prototype=c.prototype,p.prototype=new d,p.prototype.constructor=p}function n(p,c,d){if(n.isBN(p))return p;this.negative=0,this.words=null,this.length=0,this.red=null,p!==null&&((c==="le"||c==="be")&&(d=c,c=10),this._init(p||0,c||10,d||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=ud().Buffer}catch{}n.isBN=function(c){return c instanceof n?!0:c!==null&&typeof c=="object"&&c.constructor.wordSize===n.wordSize&&Array.isArray(c.words)},n.max=function(c,d){return c.cmp(d)>0?c:d},n.min=function(c,d){return c.cmp(d)<0?c:d},n.prototype._init=function(c,d,b){if(typeof c=="number")return this._initNumber(c,d,b);if(typeof c=="object")return this._initArray(c,d,b);d==="hex"&&(d=16),t(d===(d|0)&&d>=2&&d<=36),c=c.toString().replace(/\s+/g,"");var x=0;c[0]==="-"&&(x++,this.negative=1),x=0;x-=3)h=c[x]|c[x-1]<<8|c[x-2]<<16,this.words[v]|=h<<_&67108863,this.words[v+1]=h>>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);else if(b==="le")for(x=0,v=0;x>>26-_&67108863,_+=24,_>=26&&(_-=26,v++);return this._strip()};function o(p,c){var d=p.charCodeAt(c);if(d>=48&&d<=57)return d-48;if(d>=65&&d<=70)return d-55;if(d>=97&&d<=102)return d-87;t(!1,"Invalid character in "+p)}function a(p,c,d){var b=o(p,d);return d-1>=c&&(b|=o(p,d-1)<<4),b}n.prototype._parseHex=function(c,d,b){this.length=Math.ceil((c.length-d)/6),this.words=new Array(this.length);for(var x=0;x=d;x-=2)_=a(c,d,x)<=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8;else{var M=c.length-d;for(x=M%2===0?d+1:d;x=18?(v-=18,h+=1,this.words[h]|=_>>>26):v+=8}this._strip()};function f(p,c,d,b){for(var x=0,v=0,h=Math.min(p.length,d),_=c;_=49?v=M-49+10:M>=17?v=M-17+10:v=M,t(M>=0&&v1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol<"u"&&typeof Symbol.for=="function")try{n.prototype[Symbol.for("nodejs.util.inspect.custom")]=g}catch{n.prototype.inspect=g}else n.prototype.inspect=g;function g(){return(this.red?""}var y=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],S=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],I=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(c,d){c=c||10,d=d|0||1;var b;if(c===16||c==="hex"){b="";for(var x=0,v=0,h=0;h>>24-x&16777215,x+=2,x>=26&&(x-=26,h--),v!==0||h!==this.length-1?b=y[6-M.length]+M+b:b=M+b}for(v!==0&&(b=v.toString(16)+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}if(c===(c|0)&&c>=2&&c<=36){var m=S[c],T=I[c];b="";var z=this.clone();for(z.negative=0;!z.isZero();){var E=z.modrn(T).toString(c);z=z.idivn(T),z.isZero()?b=E+b:b=y[m-E.length]+E+b}for(this.isZero()&&(b="0"+b);b.length%d!==0;)b="0"+b;return this.negative!==0&&(b="-"+b),b}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var c=this.words[0];return this.length===2?c+=this.words[1]*67108864:this.length===3&&this.words[2]===1?c+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-c:c},n.prototype.toJSON=function(){return this.toString(16,2)},s&&(n.prototype.toBuffer=function(c,d){return this.toArrayLike(s,c,d)}),n.prototype.toArray=function(c,d){return this.toArrayLike(Array,c,d)};var A=function(c,d){return c.allocUnsafe?c.allocUnsafe(d):new c(d)};n.prototype.toArrayLike=function(c,d,b){this._strip();var x=this.byteLength(),v=b||Math.max(1,x);t(x<=v,"byte array longer than desired length"),t(v>0,"Requested array length <= 0");var h=A(c,v),_=d==="le"?"LE":"BE";return this["_toArrayLike"+_](h,x),h},n.prototype._toArrayLikeLE=function(c,d){for(var b=0,x=0,v=0,h=0;v>8&255),b>16&255),h===6?(b>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b=0&&(c[b--]=_>>8&255),b>=0&&(c[b--]=_>>16&255),h===6?(b>=0&&(c[b--]=_>>24&255),x=0,h=0):(x=_>>>24,h+=2)}if(b>=0)for(c[b--]=x;b>=0;)c[b--]=0},Math.clz32?n.prototype._countBits=function(c){return 32-Math.clz32(c)}:n.prototype._countBits=function(c){var d=c,b=0;return d>=4096&&(b+=13,d>>>=13),d>=64&&(b+=7,d>>>=7),d>=8&&(b+=4,d>>>=4),d>=2&&(b+=2,d>>>=2),b+d},n.prototype._zeroBits=function(c){if(c===0)return 26;var d=c,b=0;return d&8191||(b+=13,d>>>=13),d&127||(b+=7,d>>>=7),d&15||(b+=4,d>>>=4),d&3||(b+=2,d>>>=2),d&1||b++,b},n.prototype.bitLength=function(){var c=this.words[this.length-1],d=this._countBits(c);return(this.length-1)*26+d};function P(p){for(var c=new Array(p.bitLength()),d=0;d>>x&1}return c}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var c=0,d=0;dc.length?this.clone().ior(c):c.clone().ior(this)},n.prototype.uor=function(c){return this.length>c.length?this.clone().iuor(c):c.clone().iuor(this)},n.prototype.iuand=function(c){var d;this.length>c.length?d=c:d=this;for(var b=0;bc.length?this.clone().iand(c):c.clone().iand(this)},n.prototype.uand=function(c){return this.length>c.length?this.clone().iuand(c):c.clone().iuand(this)},n.prototype.iuxor=function(c){var d,b;this.length>c.length?(d=this,b=c):(d=c,b=this);for(var x=0;xc.length?this.clone().ixor(c):c.clone().ixor(this)},n.prototype.uxor=function(c){return this.length>c.length?this.clone().iuxor(c):c.clone().iuxor(this)},n.prototype.inotn=function(c){t(typeof c=="number"&&c>=0);var d=Math.ceil(c/26)|0,b=c%26;this._expand(d),b>0&&d--;for(var x=0;x0&&(this.words[x]=~this.words[x]&67108863>>26-b),this._strip()},n.prototype.notn=function(c){return this.clone().inotn(c)},n.prototype.setn=function(c,d){t(typeof c=="number"&&c>=0);var b=c/26|0,x=c%26;return this._expand(b+1),d?this.words[b]=this.words[b]|1<c.length?(b=this,x=c):(b=c,x=this);for(var v=0,h=0;h>>26;for(;v!==0&&h>>26;if(this.length=b.length,v!==0)this.words[this.length]=v,this.length++;else if(b!==this)for(;hc.length?this.clone().iadd(c):c.clone().iadd(this)},n.prototype.isub=function(c){if(c.negative!==0){c.negative=0;var d=this.iadd(c);return c.negative=1,d._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(c),this.negative=1,this._normSign();var b=this.cmp(c);if(b===0)return this.negative=0,this.length=1,this.words[0]=0,this;var x,v;b>0?(x=this,v=c):(x=c,v=this);for(var h=0,_=0;_>26,this.words[_]=d&67108863;for(;h!==0&&_>26,this.words[_]=d&67108863;if(h===0&&_>>26,z=M&67108863,E=Math.min(m,c.length-1),D=Math.max(0,m-p.length+1);D<=E;D++){var F=m-D|0;x=p.words[F]|0,v=c.words[D]|0,h=x*v+z,T+=h/67108864|0,z=h&67108863}d.words[m]=z|0,M=T|0}return M!==0?d.words[m]=M|0:d.length--,d._strip()}var N=function(c,d,b){var x=c.words,v=d.words,h=b.words,_=0,M,m,T,z=x[0]|0,E=z&8191,D=z>>>13,F=x[1]|0,q=F&8191,K=F>>>13,Y=x[2]|0,H=Y&8191,$=Y>>>13,ee=x[3]|0,G=ee&8191,X=ee>>>13,Ur=x[4]|0,se=Ur&8191,oe=Ur>>>13,qr=x[5]|0,ae=qr&8191,ce=qr>>>13,Br=x[6]|0,fe=Br&8191,ue=Br>>>13,kr=x[7]|0,he=kr&8191,de=kr>>>13,zr=x[8]|0,le=zr&8191,pe=zr>>>13,jr=x[9]|0,ge=jr&8191,me=jr>>>13,Kr=v[0]|0,be=Kr&8191,ve=Kr>>>13,Vr=v[1]|0,ye=Vr&8191,we=Vr>>>13,$r=v[2]|0,xe=$r&8191,_e=$r>>>13,Hr=v[3]|0,Ee=Hr&8191,Se=Hr>>>13,Gr=v[4]|0,Ie=Gr&8191,Ae=Gr>>>13,Wr=v[5]|0,Me=Wr&8191,Te=Wr>>>13,Jr=v[6]|0,Pe=Jr&8191,Re=Jr>>>13,Yr=v[7]|0,Ne=Yr&8191,De=Yr>>>13,Xr=v[8]|0,Ce=Xr&8191,Oe=Xr>>>13,vr=v[9]|0,Ke=vr&8191,Ve=vr>>>13;b.negative=c.negative^d.negative,b.length=19,M=Math.imul(E,be),m=Math.imul(E,ve),m=m+Math.imul(D,be)|0,T=Math.imul(D,ve);var tr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(tr>>>26)|0,tr&=67108863,M=Math.imul(q,be),m=Math.imul(q,ve),m=m+Math.imul(K,be)|0,T=Math.imul(K,ve),M=M+Math.imul(E,ye)|0,m=m+Math.imul(E,we)|0,m=m+Math.imul(D,ye)|0,T=T+Math.imul(D,we)|0;var rr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(rr>>>26)|0,rr&=67108863,M=Math.imul(H,be),m=Math.imul(H,ve),m=m+Math.imul($,be)|0,T=Math.imul($,ve),M=M+Math.imul(q,ye)|0,m=m+Math.imul(q,we)|0,m=m+Math.imul(K,ye)|0,T=T+Math.imul(K,we)|0,M=M+Math.imul(E,xe)|0,m=m+Math.imul(E,_e)|0,m=m+Math.imul(D,xe)|0,T=T+Math.imul(D,_e)|0;var ir=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(ir>>>26)|0,ir&=67108863,M=Math.imul(G,be),m=Math.imul(G,ve),m=m+Math.imul(X,be)|0,T=Math.imul(X,ve),M=M+Math.imul(H,ye)|0,m=m+Math.imul(H,we)|0,m=m+Math.imul($,ye)|0,T=T+Math.imul($,we)|0,M=M+Math.imul(q,xe)|0,m=m+Math.imul(q,_e)|0,m=m+Math.imul(K,xe)|0,T=T+Math.imul(K,_e)|0,M=M+Math.imul(E,Ee)|0,m=m+Math.imul(E,Se)|0,m=m+Math.imul(D,Ee)|0,T=T+Math.imul(D,Se)|0;var nr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(nr>>>26)|0,nr&=67108863,M=Math.imul(se,be),m=Math.imul(se,ve),m=m+Math.imul(oe,be)|0,T=Math.imul(oe,ve),M=M+Math.imul(G,ye)|0,m=m+Math.imul(G,we)|0,m=m+Math.imul(X,ye)|0,T=T+Math.imul(X,we)|0,M=M+Math.imul(H,xe)|0,m=m+Math.imul(H,_e)|0,m=m+Math.imul($,xe)|0,T=T+Math.imul($,_e)|0,M=M+Math.imul(q,Ee)|0,m=m+Math.imul(q,Se)|0,m=m+Math.imul(K,Ee)|0,T=T+Math.imul(K,Se)|0,M=M+Math.imul(E,Ie)|0,m=m+Math.imul(E,Ae)|0,m=m+Math.imul(D,Ie)|0,T=T+Math.imul(D,Ae)|0;var sr=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(sr>>>26)|0,sr&=67108863,M=Math.imul(ae,be),m=Math.imul(ae,ve),m=m+Math.imul(ce,be)|0,T=Math.imul(ce,ve),M=M+Math.imul(se,ye)|0,m=m+Math.imul(se,we)|0,m=m+Math.imul(oe,ye)|0,T=T+Math.imul(oe,we)|0,M=M+Math.imul(G,xe)|0,m=m+Math.imul(G,_e)|0,m=m+Math.imul(X,xe)|0,T=T+Math.imul(X,_e)|0,M=M+Math.imul(H,Ee)|0,m=m+Math.imul(H,Se)|0,m=m+Math.imul($,Ee)|0,T=T+Math.imul($,Se)|0,M=M+Math.imul(q,Ie)|0,m=m+Math.imul(q,Ae)|0,m=m+Math.imul(K,Ie)|0,T=T+Math.imul(K,Ae)|0,M=M+Math.imul(E,Me)|0,m=m+Math.imul(E,Te)|0,m=m+Math.imul(D,Me)|0,T=T+Math.imul(D,Te)|0;var _n=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(_n>>>26)|0,_n&=67108863,M=Math.imul(fe,be),m=Math.imul(fe,ve),m=m+Math.imul(ue,be)|0,T=Math.imul(ue,ve),M=M+Math.imul(ae,ye)|0,m=m+Math.imul(ae,we)|0,m=m+Math.imul(ce,ye)|0,T=T+Math.imul(ce,we)|0,M=M+Math.imul(se,xe)|0,m=m+Math.imul(se,_e)|0,m=m+Math.imul(oe,xe)|0,T=T+Math.imul(oe,_e)|0,M=M+Math.imul(G,Ee)|0,m=m+Math.imul(G,Se)|0,m=m+Math.imul(X,Ee)|0,T=T+Math.imul(X,Se)|0,M=M+Math.imul(H,Ie)|0,m=m+Math.imul(H,Ae)|0,m=m+Math.imul($,Ie)|0,T=T+Math.imul($,Ae)|0,M=M+Math.imul(q,Me)|0,m=m+Math.imul(q,Te)|0,m=m+Math.imul(K,Me)|0,T=T+Math.imul(K,Te)|0,M=M+Math.imul(E,Pe)|0,m=m+Math.imul(E,Re)|0,m=m+Math.imul(D,Pe)|0,T=T+Math.imul(D,Re)|0;var En=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(En>>>26)|0,En&=67108863,M=Math.imul(he,be),m=Math.imul(he,ve),m=m+Math.imul(de,be)|0,T=Math.imul(de,ve),M=M+Math.imul(fe,ye)|0,m=m+Math.imul(fe,we)|0,m=m+Math.imul(ue,ye)|0,T=T+Math.imul(ue,we)|0,M=M+Math.imul(ae,xe)|0,m=m+Math.imul(ae,_e)|0,m=m+Math.imul(ce,xe)|0,T=T+Math.imul(ce,_e)|0,M=M+Math.imul(se,Ee)|0,m=m+Math.imul(se,Se)|0,m=m+Math.imul(oe,Ee)|0,T=T+Math.imul(oe,Se)|0,M=M+Math.imul(G,Ie)|0,m=m+Math.imul(G,Ae)|0,m=m+Math.imul(X,Ie)|0,T=T+Math.imul(X,Ae)|0,M=M+Math.imul(H,Me)|0,m=m+Math.imul(H,Te)|0,m=m+Math.imul($,Me)|0,T=T+Math.imul($,Te)|0,M=M+Math.imul(q,Pe)|0,m=m+Math.imul(q,Re)|0,m=m+Math.imul(K,Pe)|0,T=T+Math.imul(K,Re)|0,M=M+Math.imul(E,Ne)|0,m=m+Math.imul(E,De)|0,m=m+Math.imul(D,Ne)|0,T=T+Math.imul(D,De)|0;var Sn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Sn>>>26)|0,Sn&=67108863,M=Math.imul(le,be),m=Math.imul(le,ve),m=m+Math.imul(pe,be)|0,T=Math.imul(pe,ve),M=M+Math.imul(he,ye)|0,m=m+Math.imul(he,we)|0,m=m+Math.imul(de,ye)|0,T=T+Math.imul(de,we)|0,M=M+Math.imul(fe,xe)|0,m=m+Math.imul(fe,_e)|0,m=m+Math.imul(ue,xe)|0,T=T+Math.imul(ue,_e)|0,M=M+Math.imul(ae,Ee)|0,m=m+Math.imul(ae,Se)|0,m=m+Math.imul(ce,Ee)|0,T=T+Math.imul(ce,Se)|0,M=M+Math.imul(se,Ie)|0,m=m+Math.imul(se,Ae)|0,m=m+Math.imul(oe,Ie)|0,T=T+Math.imul(oe,Ae)|0,M=M+Math.imul(G,Me)|0,m=m+Math.imul(G,Te)|0,m=m+Math.imul(X,Me)|0,T=T+Math.imul(X,Te)|0,M=M+Math.imul(H,Pe)|0,m=m+Math.imul(H,Re)|0,m=m+Math.imul($,Pe)|0,T=T+Math.imul($,Re)|0,M=M+Math.imul(q,Ne)|0,m=m+Math.imul(q,De)|0,m=m+Math.imul(K,Ne)|0,T=T+Math.imul(K,De)|0,M=M+Math.imul(E,Ce)|0,m=m+Math.imul(E,Oe)|0,m=m+Math.imul(D,Ce)|0,T=T+Math.imul(D,Oe)|0;var In=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(In>>>26)|0,In&=67108863,M=Math.imul(ge,be),m=Math.imul(ge,ve),m=m+Math.imul(me,be)|0,T=Math.imul(me,ve),M=M+Math.imul(le,ye)|0,m=m+Math.imul(le,we)|0,m=m+Math.imul(pe,ye)|0,T=T+Math.imul(pe,we)|0,M=M+Math.imul(he,xe)|0,m=m+Math.imul(he,_e)|0,m=m+Math.imul(de,xe)|0,T=T+Math.imul(de,_e)|0,M=M+Math.imul(fe,Ee)|0,m=m+Math.imul(fe,Se)|0,m=m+Math.imul(ue,Ee)|0,T=T+Math.imul(ue,Se)|0,M=M+Math.imul(ae,Ie)|0,m=m+Math.imul(ae,Ae)|0,m=m+Math.imul(ce,Ie)|0,T=T+Math.imul(ce,Ae)|0,M=M+Math.imul(se,Me)|0,m=m+Math.imul(se,Te)|0,m=m+Math.imul(oe,Me)|0,T=T+Math.imul(oe,Te)|0,M=M+Math.imul(G,Pe)|0,m=m+Math.imul(G,Re)|0,m=m+Math.imul(X,Pe)|0,T=T+Math.imul(X,Re)|0,M=M+Math.imul(H,Ne)|0,m=m+Math.imul(H,De)|0,m=m+Math.imul($,Ne)|0,T=T+Math.imul($,De)|0,M=M+Math.imul(q,Ce)|0,m=m+Math.imul(q,Oe)|0,m=m+Math.imul(K,Ce)|0,T=T+Math.imul(K,Oe)|0,M=M+Math.imul(E,Ke)|0,m=m+Math.imul(E,Ve)|0,m=m+Math.imul(D,Ke)|0,T=T+Math.imul(D,Ve)|0;var An=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(An>>>26)|0,An&=67108863,M=Math.imul(ge,ye),m=Math.imul(ge,we),m=m+Math.imul(me,ye)|0,T=Math.imul(me,we),M=M+Math.imul(le,xe)|0,m=m+Math.imul(le,_e)|0,m=m+Math.imul(pe,xe)|0,T=T+Math.imul(pe,_e)|0,M=M+Math.imul(he,Ee)|0,m=m+Math.imul(he,Se)|0,m=m+Math.imul(de,Ee)|0,T=T+Math.imul(de,Se)|0,M=M+Math.imul(fe,Ie)|0,m=m+Math.imul(fe,Ae)|0,m=m+Math.imul(ue,Ie)|0,T=T+Math.imul(ue,Ae)|0,M=M+Math.imul(ae,Me)|0,m=m+Math.imul(ae,Te)|0,m=m+Math.imul(ce,Me)|0,T=T+Math.imul(ce,Te)|0,M=M+Math.imul(se,Pe)|0,m=m+Math.imul(se,Re)|0,m=m+Math.imul(oe,Pe)|0,T=T+Math.imul(oe,Re)|0,M=M+Math.imul(G,Ne)|0,m=m+Math.imul(G,De)|0,m=m+Math.imul(X,Ne)|0,T=T+Math.imul(X,De)|0,M=M+Math.imul(H,Ce)|0,m=m+Math.imul(H,Oe)|0,m=m+Math.imul($,Ce)|0,T=T+Math.imul($,Oe)|0,M=M+Math.imul(q,Ke)|0,m=m+Math.imul(q,Ve)|0,m=m+Math.imul(K,Ke)|0,T=T+Math.imul(K,Ve)|0;var Mn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,M=Math.imul(ge,xe),m=Math.imul(ge,_e),m=m+Math.imul(me,xe)|0,T=Math.imul(me,_e),M=M+Math.imul(le,Ee)|0,m=m+Math.imul(le,Se)|0,m=m+Math.imul(pe,Ee)|0,T=T+Math.imul(pe,Se)|0,M=M+Math.imul(he,Ie)|0,m=m+Math.imul(he,Ae)|0,m=m+Math.imul(de,Ie)|0,T=T+Math.imul(de,Ae)|0,M=M+Math.imul(fe,Me)|0,m=m+Math.imul(fe,Te)|0,m=m+Math.imul(ue,Me)|0,T=T+Math.imul(ue,Te)|0,M=M+Math.imul(ae,Pe)|0,m=m+Math.imul(ae,Re)|0,m=m+Math.imul(ce,Pe)|0,T=T+Math.imul(ce,Re)|0,M=M+Math.imul(se,Ne)|0,m=m+Math.imul(se,De)|0,m=m+Math.imul(oe,Ne)|0,T=T+Math.imul(oe,De)|0,M=M+Math.imul(G,Ce)|0,m=m+Math.imul(G,Oe)|0,m=m+Math.imul(X,Ce)|0,T=T+Math.imul(X,Oe)|0,M=M+Math.imul(H,Ke)|0,m=m+Math.imul(H,Ve)|0,m=m+Math.imul($,Ke)|0,T=T+Math.imul($,Ve)|0;var Tn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,M=Math.imul(ge,Ee),m=Math.imul(ge,Se),m=m+Math.imul(me,Ee)|0,T=Math.imul(me,Se),M=M+Math.imul(le,Ie)|0,m=m+Math.imul(le,Ae)|0,m=m+Math.imul(pe,Ie)|0,T=T+Math.imul(pe,Ae)|0,M=M+Math.imul(he,Me)|0,m=m+Math.imul(he,Te)|0,m=m+Math.imul(de,Me)|0,T=T+Math.imul(de,Te)|0,M=M+Math.imul(fe,Pe)|0,m=m+Math.imul(fe,Re)|0,m=m+Math.imul(ue,Pe)|0,T=T+Math.imul(ue,Re)|0,M=M+Math.imul(ae,Ne)|0,m=m+Math.imul(ae,De)|0,m=m+Math.imul(ce,Ne)|0,T=T+Math.imul(ce,De)|0,M=M+Math.imul(se,Ce)|0,m=m+Math.imul(se,Oe)|0,m=m+Math.imul(oe,Ce)|0,T=T+Math.imul(oe,Oe)|0,M=M+Math.imul(G,Ke)|0,m=m+Math.imul(G,Ve)|0,m=m+Math.imul(X,Ke)|0,T=T+Math.imul(X,Ve)|0;var Pn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,M=Math.imul(ge,Ie),m=Math.imul(ge,Ae),m=m+Math.imul(me,Ie)|0,T=Math.imul(me,Ae),M=M+Math.imul(le,Me)|0,m=m+Math.imul(le,Te)|0,m=m+Math.imul(pe,Me)|0,T=T+Math.imul(pe,Te)|0,M=M+Math.imul(he,Pe)|0,m=m+Math.imul(he,Re)|0,m=m+Math.imul(de,Pe)|0,T=T+Math.imul(de,Re)|0,M=M+Math.imul(fe,Ne)|0,m=m+Math.imul(fe,De)|0,m=m+Math.imul(ue,Ne)|0,T=T+Math.imul(ue,De)|0,M=M+Math.imul(ae,Ce)|0,m=m+Math.imul(ae,Oe)|0,m=m+Math.imul(ce,Ce)|0,T=T+Math.imul(ce,Oe)|0,M=M+Math.imul(se,Ke)|0,m=m+Math.imul(se,Ve)|0,m=m+Math.imul(oe,Ke)|0,T=T+Math.imul(oe,Ve)|0;var Rn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,M=Math.imul(ge,Me),m=Math.imul(ge,Te),m=m+Math.imul(me,Me)|0,T=Math.imul(me,Te),M=M+Math.imul(le,Pe)|0,m=m+Math.imul(le,Re)|0,m=m+Math.imul(pe,Pe)|0,T=T+Math.imul(pe,Re)|0,M=M+Math.imul(he,Ne)|0,m=m+Math.imul(he,De)|0,m=m+Math.imul(de,Ne)|0,T=T+Math.imul(de,De)|0,M=M+Math.imul(fe,Ce)|0,m=m+Math.imul(fe,Oe)|0,m=m+Math.imul(ue,Ce)|0,T=T+Math.imul(ue,Oe)|0,M=M+Math.imul(ae,Ke)|0,m=m+Math.imul(ae,Ve)|0,m=m+Math.imul(ce,Ke)|0,T=T+Math.imul(ce,Ve)|0;var Nn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,M=Math.imul(ge,Pe),m=Math.imul(ge,Re),m=m+Math.imul(me,Pe)|0,T=Math.imul(me,Re),M=M+Math.imul(le,Ne)|0,m=m+Math.imul(le,De)|0,m=m+Math.imul(pe,Ne)|0,T=T+Math.imul(pe,De)|0,M=M+Math.imul(he,Ce)|0,m=m+Math.imul(he,Oe)|0,m=m+Math.imul(de,Ce)|0,T=T+Math.imul(de,Oe)|0,M=M+Math.imul(fe,Ke)|0,m=m+Math.imul(fe,Ve)|0,m=m+Math.imul(ue,Ke)|0,T=T+Math.imul(ue,Ve)|0;var Dn=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,M=Math.imul(ge,Ne),m=Math.imul(ge,De),m=m+Math.imul(me,Ne)|0,T=Math.imul(me,De),M=M+Math.imul(le,Ce)|0,m=m+Math.imul(le,Oe)|0,m=m+Math.imul(pe,Ce)|0,T=T+Math.imul(pe,Oe)|0,M=M+Math.imul(he,Ke)|0,m=m+Math.imul(he,Ve)|0,m=m+Math.imul(de,Ke)|0,T=T+Math.imul(de,Ve)|0;var qu=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(qu>>>26)|0,qu&=67108863,M=Math.imul(ge,Ce),m=Math.imul(ge,Oe),m=m+Math.imul(me,Ce)|0,T=Math.imul(me,Oe),M=M+Math.imul(le,Ke)|0,m=m+Math.imul(le,Ve)|0,m=m+Math.imul(pe,Ke)|0,T=T+Math.imul(pe,Ve)|0;var Bu=(_+M|0)+((m&8191)<<13)|0;_=(T+(m>>>13)|0)+(Bu>>>26)|0,Bu&=67108863,M=Math.imul(ge,Ke),m=Math.imul(ge,Ve),m=m+Math.imul(me,Ke)|0,T=Math.imul(me,Ve);var ku=(_+M|0)+((m&8191)<<13)|0;return _=(T+(m>>>13)|0)+(ku>>>26)|0,ku&=67108863,h[0]=tr,h[1]=rr,h[2]=ir,h[3]=nr,h[4]=sr,h[5]=_n,h[6]=En,h[7]=Sn,h[8]=In,h[9]=An,h[10]=Mn,h[11]=Tn,h[12]=Pn,h[13]=Rn,h[14]=Nn,h[15]=Dn,h[16]=qu,h[17]=Bu,h[18]=ku,_!==0&&(h[19]=_,b.length++),b};Math.imul||(N=O);function U(p,c,d){d.negative=c.negative^p.negative,d.length=p.length+c.length;for(var b=0,x=0,v=0;v>>26)|0,x+=h>>>26,h&=67108863}d.words[v]=_,b=h,h=x}return b!==0?d.words[v]=b:d.length--,d._strip()}function k(p,c,d){return U(p,c,d)}n.prototype.mulTo=function(c,d){var b,x=this.length+c.length;return this.length===10&&c.length===10?b=N(this,c,d):x<63?b=O(this,c,d):x<1024?b=U(this,c,d):b=k(this,c,d),b};function B(p,c){this.x=p,this.y=c}B.prototype.makeRBT=function(c){for(var d=new Array(c),b=n.prototype._countBits(c)-1,x=0;x>=1;return x},B.prototype.permute=function(c,d,b,x,v,h){for(var _=0;_>>1)v++;return 1<>>13,b[2*h+1]=v&8191,v=v>>>13;for(h=2*d;h>=26,b+=v/67108864|0,b+=h>>>26,this.words[x]=h&67108863}return b!==0&&(this.words[x]=b,this.length++),d?this.ineg():this},n.prototype.muln=function(c){return this.clone().imuln(c)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(c){var d=P(c);if(d.length===0)return new n(1);for(var b=this,x=0;x=0);var d=c%26,b=(c-d)/26,x=67108863>>>26-d<<26-d,v;if(d!==0){var h=0;for(v=0;v>>26-d}h&&(this.words[v]=h,this.length++)}if(b!==0){for(v=this.length-1;v>=0;v--)this.words[v+b]=this.words[v];for(v=0;v=0);var x;d?x=(d-d%26)/26:x=0;var v=c%26,h=Math.min((c-v)/26,this.length),_=67108863^67108863>>>v<h)for(this.length-=h,m=0;m=0&&(T!==0||m>=x);m--){var z=this.words[m]|0;this.words[m]=T<<26-v|z>>>v,T=z&_}return M&&T!==0&&(M.words[M.length++]=T),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},n.prototype.ishrn=function(c,d,b){return t(this.negative===0),this.iushrn(c,d,b)},n.prototype.shln=function(c){return this.clone().ishln(c)},n.prototype.ushln=function(c){return this.clone().iushln(c)},n.prototype.shrn=function(c){return this.clone().ishrn(c)},n.prototype.ushrn=function(c){return this.clone().iushrn(c)},n.prototype.testn=function(c){t(typeof c=="number"&&c>=0);var d=c%26,b=(c-d)/26,x=1<=0);var d=c%26,b=(c-d)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=b)return this;if(d!==0&&b++,this.length=Math.min(b,this.length),d!==0){var x=67108863^67108863>>>d<=67108864;d++)this.words[d]-=67108864,d===this.length-1?this.words[d+1]=1:this.words[d+1]++;return this.length=Math.max(this.length,d+1),this},n.prototype.isubn=function(c){if(t(typeof c=="number"),t(c<67108864),c<0)return this.iaddn(-c);if(this.negative!==0)return this.negative=0,this.iaddn(c),this.negative=1,this;if(this.words[0]-=c,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var d=0;d>26)-(M/67108864|0),this.words[v+b]=h&67108863}for(;v>26,this.words[v+b]=h&67108863;if(_===0)return this._strip();for(t(_===-1),_=0,v=0;v>26,this.words[v]=h&67108863;return this.negative=1,this._strip()},n.prototype._wordDiv=function(c,d){var b=this.length-c.length,x=this.clone(),v=c,h=v.words[v.length-1]|0,_=this._countBits(h);b=26-_,b!==0&&(v=v.ushln(b),x.iushln(b),h=v.words[v.length-1]|0);var M=x.length-v.length,m;if(d!=="mod"){m=new n(null),m.length=M+1,m.words=new Array(m.length);for(var T=0;T=0;E--){var D=(x.words[v.length+E]|0)*67108864+(x.words[v.length+E-1]|0);for(D=Math.min(D/h|0,67108863),x._ishlnsubmul(v,D,E);x.negative!==0;)D--,x.negative=0,x._ishlnsubmul(v,1,E),x.isZero()||(x.negative^=1);m&&(m.words[E]=D)}return m&&m._strip(),x._strip(),d!=="div"&&b!==0&&x.iushrn(b),{div:m||null,mod:x}},n.prototype.divmod=function(c,d,b){if(t(!c.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var x,v,h;return this.negative!==0&&c.negative===0?(h=this.neg().divmod(c,d),d!=="mod"&&(x=h.div.neg()),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.iadd(c)),{div:x,mod:v}):this.negative===0&&c.negative!==0?(h=this.divmod(c.neg(),d),d!=="mod"&&(x=h.div.neg()),{div:x,mod:h.mod}):this.negative&c.negative?(h=this.neg().divmod(c.neg(),d),d!=="div"&&(v=h.mod.neg(),b&&v.negative!==0&&v.isub(c)),{div:h.div,mod:v}):c.length>this.length||this.cmp(c)<0?{div:new n(0),mod:this}:c.length===1?d==="div"?{div:this.divn(c.words[0]),mod:null}:d==="mod"?{div:null,mod:new n(this.modrn(c.words[0]))}:{div:this.divn(c.words[0]),mod:new n(this.modrn(c.words[0]))}:this._wordDiv(c,d)},n.prototype.div=function(c){return this.divmod(c,"div",!1).div},n.prototype.mod=function(c){return this.divmod(c,"mod",!1).mod},n.prototype.umod=function(c){return this.divmod(c,"mod",!0).mod},n.prototype.divRound=function(c){var d=this.divmod(c);if(d.mod.isZero())return d.div;var b=d.div.negative!==0?d.mod.isub(c):d.mod,x=c.ushrn(1),v=c.andln(1),h=b.cmp(x);return h<0||v===1&&h===0?d.div:d.div.negative!==0?d.div.isubn(1):d.div.iaddn(1)},n.prototype.modrn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=(1<<26)%c,x=0,v=this.length-1;v>=0;v--)x=(b*x+(this.words[v]|0))%c;return d?-x:x},n.prototype.modn=function(c){return this.modrn(c)},n.prototype.idivn=function(c){var d=c<0;d&&(c=-c),t(c<=67108863);for(var b=0,x=this.length-1;x>=0;x--){var v=(this.words[x]|0)+b*67108864;this.words[x]=v/c|0,b=v%c}return this._strip(),d?this.ineg():this},n.prototype.divn=function(c){return this.clone().idivn(c)},n.prototype.egcd=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=new n(0),_=new n(1),M=0;d.isEven()&&b.isEven();)d.iushrn(1),b.iushrn(1),++M;for(var m=b.clone(),T=d.clone();!d.isZero();){for(var z=0,E=1;!(d.words[0]&E)&&z<26;++z,E<<=1);if(z>0)for(d.iushrn(z);z-- >0;)(x.isOdd()||v.isOdd())&&(x.iadd(m),v.isub(T)),x.iushrn(1),v.iushrn(1);for(var D=0,F=1;!(b.words[0]&F)&&D<26;++D,F<<=1);if(D>0)for(b.iushrn(D);D-- >0;)(h.isOdd()||_.isOdd())&&(h.iadd(m),_.isub(T)),h.iushrn(1),_.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(h),v.isub(_)):(b.isub(d),h.isub(x),_.isub(v))}return{a:h,b:_,gcd:b.iushln(M)}},n.prototype._invmp=function(c){t(c.negative===0),t(!c.isZero());var d=this,b=c.clone();d.negative!==0?d=d.umod(c):d=d.clone();for(var x=new n(1),v=new n(0),h=b.clone();d.cmpn(1)>0&&b.cmpn(1)>0;){for(var _=0,M=1;!(d.words[0]&M)&&_<26;++_,M<<=1);if(_>0)for(d.iushrn(_);_-- >0;)x.isOdd()&&x.iadd(h),x.iushrn(1);for(var m=0,T=1;!(b.words[0]&T)&&m<26;++m,T<<=1);if(m>0)for(b.iushrn(m);m-- >0;)v.isOdd()&&v.iadd(h),v.iushrn(1);d.cmp(b)>=0?(d.isub(b),x.isub(v)):(b.isub(d),v.isub(x))}var z;return d.cmpn(1)===0?z=x:z=v,z.cmpn(0)<0&&z.iadd(c),z},n.prototype.gcd=function(c){if(this.isZero())return c.abs();if(c.isZero())return this.abs();var d=this.clone(),b=c.clone();d.negative=0,b.negative=0;for(var x=0;d.isEven()&&b.isEven();x++)d.iushrn(1),b.iushrn(1);do{for(;d.isEven();)d.iushrn(1);for(;b.isEven();)b.iushrn(1);var v=d.cmp(b);if(v<0){var h=d;d=b,b=h}else if(v===0||b.cmpn(1)===0)break;d.isub(b)}while(!0);return b.iushln(x)},n.prototype.invm=function(c){return this.egcd(c).a.umod(c)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(c){return this.words[0]&c},n.prototype.bincn=function(c){t(typeof c=="number");var d=c%26,b=(c-d)/26,x=1<>>26,_&=67108863,this.words[h]=_}return v!==0&&(this.words[h]=v,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(c){var d=c<0;if(this.negative!==0&&!d)return-1;if(this.negative===0&&d)return 1;this._strip();var b;if(this.length>1)b=1;else{d&&(c=-c),t(c<=67108863,"Number is too big");var x=this.words[0]|0;b=x===c?0:xc.length)return 1;if(this.length=0;b--){var x=this.words[b]|0,v=c.words[b]|0;if(x!==v){xv&&(d=1);break}}return d},n.prototype.gtn=function(c){return this.cmpn(c)===1},n.prototype.gt=function(c){return this.cmp(c)===1},n.prototype.gten=function(c){return this.cmpn(c)>=0},n.prototype.gte=function(c){return this.cmp(c)>=0},n.prototype.ltn=function(c){return this.cmpn(c)===-1},n.prototype.lt=function(c){return this.cmp(c)===-1},n.prototype.lten=function(c){return this.cmpn(c)<=0},n.prototype.lte=function(c){return this.cmp(c)<=0},n.prototype.eqn=function(c){return this.cmpn(c)===0},n.prototype.eq=function(c){return this.cmp(c)===0},n.red=function(c){return new l(c)},n.prototype.toRed=function(c){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),c.convertTo(this)._forceRed(c)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(c){return this.red=c,this},n.prototype.forceRed=function(c){return t(!this.red,"Already a number in reduction context"),this._forceRed(c)},n.prototype.redAdd=function(c){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,c)},n.prototype.redIAdd=function(c){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,c)},n.prototype.redSub=function(c){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,c)},n.prototype.redISub=function(c){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,c)},n.prototype.redShl=function(c){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,c)},n.prototype.redMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.mul(this,c)},n.prototype.redIMul=function(c){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,c),this.red.imul(this,c)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(c){return t(this.red&&!c.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,c)};var j={k256:null,p224:null,p192:null,p25519:null};function V(p,c){this.name=p,this.p=new n(c,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}V.prototype._tmp=function(){var c=new n(null);return c.words=new Array(Math.ceil(this.n/13)),c},V.prototype.ireduce=function(c){var d=c,b;do this.split(d,this.tmp),d=this.imulK(d),d=d.iadd(this.tmp),b=d.bitLength();while(b>this.n);var x=b0?d.isub(this.p):d.strip!==void 0?d.strip():d._strip(),d},V.prototype.split=function(c,d){c.iushrn(this.n,0,d)},V.prototype.imulK=function(c){return c.imul(this.k)};function L(){V.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(L,V),L.prototype.split=function(c,d){for(var b=4194303,x=Math.min(c.length,9),v=0;v>>22,h=_}h>>>=22,c.words[v-10]=h,h===0&&c.length>10?c.length-=10:c.length-=9},L.prototype.imulK=function(c){c.words[c.length]=0,c.words[c.length+1]=0,c.length+=2;for(var d=0,b=0;b>>=26,c.words[b]=v,d=x}return d!==0&&(c.words[c.length++]=d),c},n._prime=function(c){if(j[c])return j[c];var d;if(c==="k256")d=new L;else if(c==="p224")d=new C;else if(c==="p192")d=new W;else if(c==="p25519")d=new R;else throw new Error("Unknown prime "+c);return j[c]=d,d};function l(p){if(typeof p=="string"){var c=n._prime(p);this.m=c.p,this.prime=c}else t(p.gtn(1),"modulus must be greater than 1"),this.m=p,this.prime=null}l.prototype._verify1=function(c){t(c.negative===0,"red works only with positives"),t(c.red,"red works only with red numbers")},l.prototype._verify2=function(c,d){t((c.negative|d.negative)===0,"red works only with positives"),t(c.red&&c.red===d.red,"red works only with red numbers")},l.prototype.imod=function(c){return this.prime?this.prime.ireduce(c)._forceRed(this):(u(c,c.umod(this.m)._forceRed(this)),c)},l.prototype.neg=function(c){return c.isZero()?c.clone():this.m.sub(c)._forceRed(this)},l.prototype.add=function(c,d){this._verify2(c,d);var b=c.add(d);return b.cmp(this.m)>=0&&b.isub(this.m),b._forceRed(this)},l.prototype.iadd=function(c,d){this._verify2(c,d);var b=c.iadd(d);return b.cmp(this.m)>=0&&b.isub(this.m),b},l.prototype.sub=function(c,d){this._verify2(c,d);var b=c.sub(d);return b.cmpn(0)<0&&b.iadd(this.m),b._forceRed(this)},l.prototype.isub=function(c,d){this._verify2(c,d);var b=c.isub(d);return b.cmpn(0)<0&&b.iadd(this.m),b},l.prototype.shl=function(c,d){return this._verify1(c),this.imod(c.ushln(d))},l.prototype.imul=function(c,d){return this._verify2(c,d),this.imod(c.imul(d))},l.prototype.mul=function(c,d){return this._verify2(c,d),this.imod(c.mul(d))},l.prototype.isqr=function(c){return this.imul(c,c.clone())},l.prototype.sqr=function(c){return this.mul(c,c)},l.prototype.sqrt=function(c){if(c.isZero())return c.clone();var d=this.m.andln(3);if(t(d%2===1),d===3){var b=this.m.add(new n(1)).iushrn(2);return this.pow(c,b)}for(var x=this.m.subn(1),v=0;!x.isZero()&&x.andln(1)===0;)v++,x.iushrn(1);t(!x.isZero());var h=new n(1).toRed(this),_=h.redNeg(),M=this.m.subn(1).iushrn(1),m=this.m.bitLength();for(m=new n(2*m*m).toRed(this);this.pow(m,M).cmp(_)!==0;)m.redIAdd(_);for(var T=this.pow(m,x),z=this.pow(c,x.addn(1).iushrn(1)),E=this.pow(c,x),D=v;E.cmp(h)!==0;){for(var F=E,q=0;F.cmp(h)!==0;q++)F=F.redSqr();t(q=0;v--){for(var T=d.words[v],z=m-1;z>=0;z--){var E=T>>z&1;if(h!==x[0]&&(h=this.sqr(h)),E===0&&_===0){M=0;continue}_<<=1,_|=E,M++,!(M!==b&&(v!==0||z!==0))&&(h=this.mul(h,x[_]),M=0,_=0)}m=26}return h},l.prototype.convertTo=function(c){var d=c.umod(this.m);return d===c?d.clone():d},l.prototype.convertFrom=function(c){var d=c.clone();return d.red=null,d},n.mont=function(c){return new w(c)};function w(p){l.call(this,p),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(w,l),w.prototype.convertTo=function(c){return this.imod(c.ushln(this.shift))},w.prototype.convertFrom=function(c){var d=this.imod(c.mul(this.rinv));return d.red=null,d},w.prototype.imul=function(c,d){if(c.isZero()||d.isZero())return c.words[0]=0,c.length=1,c;var b=c.imul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.mul=function(c,d){if(c.isZero()||d.isZero())return new n(0)._forceRed(this);var b=c.mul(d),x=b.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),v=b.isub(x).iushrn(this.shift),h=v;return v.cmp(this.m)>=0?h=v.isub(this.m):v.cmpn(0)<0&&(h=v.iadd(this.m)),h._forceRed(this)},w.prototype.invm=function(c){var d=this.imod(c._invmp(this.m).mul(this.r2));return d._forceRed(this)}})(typeof hd>"u"||hd,pm)});var Wi=J((mD,Mm)=>{Mm.exports=Am;function Am(r,e){if(!r)throw new Error(e||"Assertion failed")}Am.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}});var sa=J((bD,gd)=>{typeof Object.create=="function"?gd.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:gd.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}});var Ir=J(Ge=>{"use strict";var b8=Wi(),v8=sa();Ge.inherits=v8;function y8(r,e){return(r.charCodeAt(e)&64512)!==55296||e<0||e+1>=r.length?!1:(r.charCodeAt(e+1)&64512)===56320}function w8(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r=="string")if(e){if(e==="hex")for(r=r.replace(/[^a-z0-9]+/ig,""),r.length%2!==0&&(r="0"+r),n=0;n>6|192,t[i++]=s&63|128):y8(r,n)?(s=65536+((s&1023)<<10)+(r.charCodeAt(++n)&1023),t[i++]=s>>18|240,t[i++]=s>>12&63|128,t[i++]=s>>6&63|128,t[i++]=s&63|128):(t[i++]=s>>12|224,t[i++]=s>>6&63|128,t[i++]=s&63|128)}else for(n=0;n>>24|r>>>8&65280|r<<8&16711680|(r&255)<<24;return e>>>0}Ge.htonl=Tm;function _8(r,e){for(var t="",i=0;i>>0}return s}Ge.join32=E8;function S8(r,e){for(var t=new Array(r.length*4),i=0,n=0;i>>24,t[n+1]=s>>>16&255,t[n+2]=s>>>8&255,t[n+3]=s&255):(t[n+3]=s>>>24,t[n+2]=s>>>16&255,t[n+1]=s>>>8&255,t[n]=s&255)}return t}Ge.split32=S8;function I8(r,e){return r>>>e|r<<32-e}Ge.rotr32=I8;function A8(r,e){return r<>>32-e}Ge.rotl32=A8;function M8(r,e){return r+e>>>0}Ge.sum32=M8;function T8(r,e,t){return r+e+t>>>0}Ge.sum32_3=T8;function P8(r,e,t,i){return r+e+t+i>>>0}Ge.sum32_4=P8;function R8(r,e,t,i,n){return r+e+t+i+n>>>0}Ge.sum32_5=R8;function N8(r,e,t,i){var n=r[e],s=r[e+1],o=i+s>>>0,a=(o>>0,r[e+1]=o}Ge.sum64=N8;function D8(r,e,t,i){var n=e+i>>>0,s=(n>>0}Ge.sum64_hi=D8;function C8(r,e,t,i){var n=e+i;return n>>>0}Ge.sum64_lo=C8;function O8(r,e,t,i,n,s,o,a){var f=0,u=e;u=u+i>>>0,f+=u>>0,f+=u>>0,f+=u>>0}Ge.sum64_4_hi=O8;function L8(r,e,t,i,n,s,o,a){var f=e+i+s+a;return f>>>0}Ge.sum64_4_lo=L8;function F8(r,e,t,i,n,s,o,a,f,u){var g=0,y=e;y=y+i>>>0,g+=y>>0,g+=y>>0,g+=y>>0,g+=y>>0}Ge.sum64_5_hi=F8;function U8(r,e,t,i,n,s,o,a,f,u){var g=e+i+s+a+u;return g>>>0}Ge.sum64_5_lo=U8;function q8(r,e,t){var i=e<<32-t|r>>>t;return i>>>0}Ge.rotr64_hi=q8;function B8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.rotr64_lo=B8;function k8(r,e,t){return r>>>t}Ge.shr64_hi=k8;function z8(r,e,t){var i=r<<32-t|e>>>t;return i>>>0}Ge.shr64_lo=z8});var Bs=J(Dm=>{"use strict";var Nm=Ir(),j8=Wi();function af(){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}Dm.BlockHash=af;af.prototype.update=function(e,t){if(e=Nm.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){e=this.pending;var i=e.length%this._delta8;this.pending=e.slice(e.length-i,e.length),this.pending.length===0&&(this.pending=null),e=Nm.join32(e,0,e.length-i,this.endian);for(var n=0;n>>24&255,n[s++]=e>>>16&255,n[s++]=e>>>8&255,n[s++]=e&255}else for(n[s++]=e&255,n[s++]=e>>>8&255,n[s++]=e>>>16&255,n[s++]=e>>>24&255,n[s++]=0,n[s++]=0,n[s++]=0,n[s++]=0,o=8;o{"use strict";var K8=Ir(),ti=K8.rotr32;function V8(r,e,t,i){if(r===0)return Cm(e,t,i);if(r===1||r===3)return Lm(e,t,i);if(r===2)return Om(e,t,i)}Mi.ft_1=V8;function Cm(r,e,t){return r&e^~r&t}Mi.ch32=Cm;function Om(r,e,t){return r&e^r&t^e&t}Mi.maj32=Om;function Lm(r,e,t){return r^e^t}Mi.p32=Lm;function $8(r){return ti(r,2)^ti(r,13)^ti(r,22)}Mi.s0_256=$8;function H8(r){return ti(r,6)^ti(r,11)^ti(r,25)}Mi.s1_256=H8;function G8(r){return ti(r,7)^ti(r,18)^r>>>3}Mi.g0_256=G8;function W8(r){return ti(r,17)^ti(r,19)^r>>>10}Mi.g1_256=W8});var qm=J((xD,Um)=>{"use strict";var ks=Ir(),J8=Bs(),Y8=md(),bd=ks.rotl32,oa=ks.sum32,X8=ks.sum32_5,Q8=Y8.ft_1,Fm=J8.BlockHash,Z8=[1518500249,1859775393,2400959708,3395469782];function ri(){if(!(this instanceof ri))return new ri;Fm.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}ks.inherits(ri,Fm);Um.exports=ri;ri.blockSize=512;ri.outSize=160;ri.hmacStrength=80;ri.padLength=64;ri.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var zs=Ir(),e_=Bs(),js=md(),t_=Wi(),Ar=zs.sum32,r_=zs.sum32_4,i_=zs.sum32_5,n_=js.ch32,s_=js.maj32,o_=js.s0_256,a_=js.s1_256,c_=js.g0_256,f_=js.g1_256,Bm=e_.BlockHash,u_=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function ii(){if(!(this instanceof ii))return new ii;Bm.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=u_,this.W=new Array(64)}zs.inherits(ii,Bm);km.exports=ii;ii.blockSize=512;ii.outSize=256;ii.hmacStrength=192;ii.padLength=64;ii.prototype._update=function(e,t){for(var i=this.W,n=0;n<16;n++)i[n]=e[t+n];for(;n{"use strict";var yd=Ir(),zm=vd();function Ti(){if(!(this instanceof Ti))return new Ti;zm.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}yd.inherits(Ti,zm);jm.exports=Ti;Ti.blockSize=512;Ti.outSize=224;Ti.hmacStrength=192;Ti.padLength=64;Ti.prototype._digest=function(e){return e==="hex"?yd.toHex32(this.h.slice(0,7),"big"):yd.split32(this.h.slice(0,7),"big")}});var _d=J((SD,Gm)=>{"use strict";var jt=Ir(),h_=Bs(),d_=Wi(),ni=jt.rotr64_hi,si=jt.rotr64_lo,Vm=jt.shr64_hi,$m=jt.shr64_lo,Ji=jt.sum64,wd=jt.sum64_hi,xd=jt.sum64_lo,l_=jt.sum64_4_hi,p_=jt.sum64_4_lo,g_=jt.sum64_5_hi,m_=jt.sum64_5_lo,Hm=h_.BlockHash,b_=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function Mr(){if(!(this instanceof Mr))return new Mr;Hm.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=b_,this.W=new Array(160)}jt.inherits(Mr,Hm);Gm.exports=Mr;Mr.blockSize=1024;Mr.outSize=512;Mr.hmacStrength=192;Mr.padLength=128;Mr.prototype._prepareBlock=function(e,t){for(var i=this.W,n=0;n<32;n++)i[n]=e[t+n];for(;n{"use strict";var Ed=Ir(),Wm=_d();function Pi(){if(!(this instanceof Pi))return new Pi;Wm.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}Ed.inherits(Pi,Wm);Jm.exports=Pi;Pi.blockSize=1024;Pi.outSize=384;Pi.hmacStrength=192;Pi.padLength=128;Pi.prototype._digest=function(e){return e==="hex"?Ed.toHex32(this.h.slice(0,12),"big"):Ed.split32(this.h.slice(0,12),"big")}});var Xm=J(Ks=>{"use strict";Ks.sha1=qm();Ks.sha224=Km();Ks.sha256=vd();Ks.sha384=Ym();Ks.sha512=_d()});var ib=J(rb=>{"use strict";var Hn=Ir(),R_=Bs(),cf=Hn.rotl32,Qm=Hn.sum32,aa=Hn.sum32_3,Zm=Hn.sum32_4,tb=R_.BlockHash;function oi(){if(!(this instanceof oi))return new oi;tb.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}Hn.inherits(oi,tb);rb.ripemd160=oi;oi.blockSize=512;oi.outSize=160;oi.hmacStrength=192;oi.padLength=64;oi.prototype._update=function(e,t){for(var i=this.h[0],n=this.h[1],s=this.h[2],o=this.h[3],a=this.h[4],f=i,u=n,g=s,y=o,S=a,I=0;I<80;I++){var A=Qm(cf(Zm(i,eb(I,n,s,o),e[C_[I]+t],N_(I)),L_[I]),a);i=a,a=o,o=cf(s,10),s=n,n=A,A=Qm(cf(Zm(f,eb(79-I,u,g,y),e[O_[I]+t],D_(I)),F_[I]),S),f=S,S=y,y=cf(g,10),g=u,u=A}A=aa(this.h[1],s,y),this.h[1]=aa(this.h[2],o,S),this.h[2]=aa(this.h[3],a,f),this.h[3]=aa(this.h[4],i,u),this.h[4]=aa(this.h[0],n,g),this.h[0]=A};oi.prototype._digest=function(e){return e==="hex"?Hn.toHex32(this.h,"little"):Hn.split32(this.h,"little")};function eb(r,e,t,i){return r<=15?e^t^i:r<=31?e&t|~e&i:r<=47?(e|~t)^i:r<=63?e&i|t&~i:e^(t|~i)}function N_(r){return r<=15?0:r<=31?1518500249:r<=47?1859775393:r<=63?2400959708:2840853838}function D_(r){return r<=15?1352829926:r<=31?1548603684:r<=47?1836072691:r<=63?2053994217:0}var C_=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],O_=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],L_=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],F_=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]});var sb=J((TD,nb)=>{"use strict";var U_=Ir(),q_=Wi();function Vs(r,e,t){if(!(this instanceof Vs))return new Vs(r,e,t);this.Hash=r,this.blockSize=r.blockSize/8,this.outSize=r.outSize/8,this.inner=null,this.outer=null,this._init(U_.toArray(e,t))}nb.exports=Vs;Vs.prototype._init=function(e){e.length>this.blockSize&&(e=new this.Hash().update(e).digest()),q_(e.length<=this.blockSize);for(var t=e.length;t{var xt=ob;xt.utils=Ir();xt.common=Bs();xt.sha=Xm();xt.ripemd=ib();xt.hmac=sb();xt.sha1=xt.sha.sha1;xt.sha256=xt.sha.sha256;xt.sha224=xt.sha.sha224;xt.sha384=xt.sha.sha384;xt.sha512=xt.sha.sha512;xt.ripemd160=xt.ripemd.ripemd160});var vb=J(gf=>{"use strict";Object.defineProperty(gf,"__esModule",{value:!0});var Nt=Is(),Od=cr(),J_=20;function Y_(r,e,t){for(var i=1634760805,n=857760878,s=2036477234,o=1797285236,a=t[3]<<24|t[2]<<16|t[1]<<8|t[0],f=t[7]<<24|t[6]<<16|t[5]<<8|t[4],u=t[11]<<24|t[10]<<16|t[9]<<8|t[8],g=t[15]<<24|t[14]<<16|t[13]<<8|t[12],y=t[19]<<24|t[18]<<16|t[17]<<8|t[16],S=t[23]<<24|t[22]<<16|t[21]<<8|t[20],I=t[27]<<24|t[26]<<16|t[25]<<8|t[24],A=t[31]<<24|t[30]<<16|t[29]<<8|t[28],P=e[3]<<24|e[2]<<16|e[1]<<8|e[0],O=e[7]<<24|e[6]<<16|e[5]<<8|e[4],N=e[11]<<24|e[10]<<16|e[9]<<8|e[8],U=e[15]<<24|e[14]<<16|e[13]<<8|e[12],k=i,B=n,j=s,V=o,L=a,C=f,W=u,R=g,l=y,w=S,p=I,c=A,d=P,b=O,x=N,v=U,h=0;h>>16|d<<16,l=l+d|0,L^=l,L=L>>>20|L<<12,B=B+C|0,b^=B,b=b>>>16|b<<16,w=w+b|0,C^=w,C=C>>>20|C<<12,j=j+W|0,x^=j,x=x>>>16|x<<16,p=p+x|0,W^=p,W=W>>>20|W<<12,V=V+R|0,v^=V,v=v>>>16|v<<16,c=c+v|0,R^=c,R=R>>>20|R<<12,j=j+W|0,x^=j,x=x>>>24|x<<8,p=p+x|0,W^=p,W=W>>>25|W<<7,V=V+R|0,v^=V,v=v>>>24|v<<8,c=c+v|0,R^=c,R=R>>>25|R<<7,B=B+C|0,b^=B,b=b>>>24|b<<8,w=w+b|0,C^=w,C=C>>>25|C<<7,k=k+L|0,d^=k,d=d>>>24|d<<8,l=l+d|0,L^=l,L=L>>>25|L<<7,k=k+C|0,v^=k,v=v>>>16|v<<16,p=p+v|0,C^=p,C=C>>>20|C<<12,B=B+W|0,d^=B,d=d>>>16|d<<16,c=c+d|0,W^=c,W=W>>>20|W<<12,j=j+R|0,b^=j,b=b>>>16|b<<16,l=l+b|0,R^=l,R=R>>>20|R<<12,V=V+L|0,x^=V,x=x>>>16|x<<16,w=w+x|0,L^=w,L=L>>>20|L<<12,j=j+R|0,b^=j,b=b>>>24|b<<8,l=l+b|0,R^=l,R=R>>>25|R<<7,V=V+L|0,x^=V,x=x>>>24|x<<8,w=w+x|0,L^=w,L=L>>>25|L<<7,B=B+W|0,d^=B,d=d>>>24|d<<8,c=c+d|0,W^=c,W=W>>>25|W<<7,k=k+C|0,v^=k,v=v>>>24|v<<8,p=p+v|0,C^=p,C=C>>>25|C<<7;Nt.writeUint32LE(k+i|0,r,0),Nt.writeUint32LE(B+n|0,r,4),Nt.writeUint32LE(j+s|0,r,8),Nt.writeUint32LE(V+o|0,r,12),Nt.writeUint32LE(L+a|0,r,16),Nt.writeUint32LE(C+f|0,r,20),Nt.writeUint32LE(W+u|0,r,24),Nt.writeUint32LE(R+g|0,r,28),Nt.writeUint32LE(l+y|0,r,32),Nt.writeUint32LE(w+S|0,r,36),Nt.writeUint32LE(p+I|0,r,40),Nt.writeUint32LE(c+A|0,r,44),Nt.writeUint32LE(d+P|0,r,48),Nt.writeUint32LE(b+O|0,r,52),Nt.writeUint32LE(x+N|0,r,56),Nt.writeUint32LE(v+U|0,r,60)}function bb(r,e,t,i,n){if(n===void 0&&(n=0),r.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(i.length>>=8,e++;if(i>0)throw new Error("ChaCha: counter overflow")}});var mf=J(Hs=>{"use strict";Object.defineProperty(Hs,"__esModule",{value:!0});function Z_(r,e,t){return~(r-1)&e|r-1&t}Hs.select=Z_;function eE(r,e){return(r|0)-(e|0)-1>>>31&1}Hs.lessOrEqual=eE;function yb(r,e){if(r.length!==e.length)return 0;for(var t=0,i=0;i>>8}Hs.compare=yb;function tE(r,e){return r.length===0||e.length===0?!1:yb(r,e)!==0}Hs.equal=tE});var xb=J(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});var rE=mf(),bf=cr();Ri.DIGEST_LENGTH=16;var wb=function(){function r(e){this.digestLength=Ri.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var t=e[0]|e[1]<<8;this._r[0]=t&8191;var i=e[2]|e[3]<<8;this._r[1]=(t>>>13|i<<3)&8191;var n=e[4]|e[5]<<8;this._r[2]=(i>>>10|n<<6)&7939;var s=e[6]|e[7]<<8;this._r[3]=(n>>>7|s<<9)&8191;var o=e[8]|e[9]<<8;this._r[4]=(s>>>4|o<<12)&255,this._r[5]=o>>>1&8190;var a=e[10]|e[11]<<8;this._r[6]=(o>>>14|a<<2)&8191;var f=e[12]|e[13]<<8;this._r[7]=(a>>>11|f<<5)&8065;var u=e[14]|e[15]<<8;this._r[8]=(f>>>8|u<<8)&8191,this._r[9]=u>>>5&127,this._pad[0]=e[16]|e[17]<<8,this._pad[1]=e[18]|e[19]<<8,this._pad[2]=e[20]|e[21]<<8,this._pad[3]=e[22]|e[23]<<8,this._pad[4]=e[24]|e[25]<<8,this._pad[5]=e[26]|e[27]<<8,this._pad[6]=e[28]|e[29]<<8,this._pad[7]=e[30]|e[31]<<8}return r.prototype._blocks=function(e,t,i){for(var n=this._fin?0:2048,s=this._h[0],o=this._h[1],a=this._h[2],f=this._h[3],u=this._h[4],g=this._h[5],y=this._h[6],S=this._h[7],I=this._h[8],A=this._h[9],P=this._r[0],O=this._r[1],N=this._r[2],U=this._r[3],k=this._r[4],B=this._r[5],j=this._r[6],V=this._r[7],L=this._r[8],C=this._r[9];i>=16;){var W=e[t+0]|e[t+1]<<8;s+=W&8191;var R=e[t+2]|e[t+3]<<8;o+=(W>>>13|R<<3)&8191;var l=e[t+4]|e[t+5]<<8;a+=(R>>>10|l<<6)&8191;var w=e[t+6]|e[t+7]<<8;f+=(l>>>7|w<<9)&8191;var p=e[t+8]|e[t+9]<<8;u+=(w>>>4|p<<12)&8191,g+=p>>>1&8191;var c=e[t+10]|e[t+11]<<8;y+=(p>>>14|c<<2)&8191;var d=e[t+12]|e[t+13]<<8;S+=(c>>>11|d<<5)&8191;var b=e[t+14]|e[t+15]<<8;I+=(d>>>8|b<<8)&8191,A+=b>>>5|n;var x=0,v=x;v+=s*P,v+=o*(5*C),v+=a*(5*L),v+=f*(5*V),v+=u*(5*j),x=v>>>13,v&=8191,v+=g*(5*B),v+=y*(5*k),v+=S*(5*U),v+=I*(5*N),v+=A*(5*O),x+=v>>>13,v&=8191;var h=x;h+=s*O,h+=o*P,h+=a*(5*C),h+=f*(5*L),h+=u*(5*V),x=h>>>13,h&=8191,h+=g*(5*j),h+=y*(5*B),h+=S*(5*k),h+=I*(5*U),h+=A*(5*N),x+=h>>>13,h&=8191;var _=x;_+=s*N,_+=o*O,_+=a*P,_+=f*(5*C),_+=u*(5*L),x=_>>>13,_&=8191,_+=g*(5*V),_+=y*(5*j),_+=S*(5*B),_+=I*(5*k),_+=A*(5*U),x+=_>>>13,_&=8191;var M=x;M+=s*U,M+=o*N,M+=a*O,M+=f*P,M+=u*(5*C),x=M>>>13,M&=8191,M+=g*(5*L),M+=y*(5*V),M+=S*(5*j),M+=I*(5*B),M+=A*(5*k),x+=M>>>13,M&=8191;var m=x;m+=s*k,m+=o*U,m+=a*N,m+=f*O,m+=u*P,x=m>>>13,m&=8191,m+=g*(5*C),m+=y*(5*L),m+=S*(5*V),m+=I*(5*j),m+=A*(5*B),x+=m>>>13,m&=8191;var T=x;T+=s*B,T+=o*k,T+=a*U,T+=f*N,T+=u*O,x=T>>>13,T&=8191,T+=g*P,T+=y*(5*C),T+=S*(5*L),T+=I*(5*V),T+=A*(5*j),x+=T>>>13,T&=8191;var z=x;z+=s*j,z+=o*B,z+=a*k,z+=f*U,z+=u*N,x=z>>>13,z&=8191,z+=g*O,z+=y*P,z+=S*(5*C),z+=I*(5*L),z+=A*(5*V),x+=z>>>13,z&=8191;var E=x;E+=s*V,E+=o*j,E+=a*B,E+=f*k,E+=u*U,x=E>>>13,E&=8191,E+=g*N,E+=y*O,E+=S*P,E+=I*(5*C),E+=A*(5*L),x+=E>>>13,E&=8191;var D=x;D+=s*L,D+=o*V,D+=a*j,D+=f*B,D+=u*k,x=D>>>13,D&=8191,D+=g*U,D+=y*N,D+=S*O,D+=I*P,D+=A*(5*C),x+=D>>>13,D&=8191;var F=x;F+=s*C,F+=o*L,F+=a*V,F+=f*j,F+=u*B,x=F>>>13,F&=8191,F+=g*k,F+=y*U,F+=S*N,F+=I*O,F+=A*P,x+=F>>>13,F&=8191,x=(x<<2)+x|0,x=x+v|0,v=x&8191,x=x>>>13,h+=x,s=v,o=h,a=_,f=M,u=m,g=T,y=z,S=E,I=D,A=F,t+=16,i-=16}this._h[0]=s,this._h[1]=o,this._h[2]=a,this._h[3]=f,this._h[4]=u,this._h[5]=g,this._h[6]=y,this._h[7]=S,this._h[8]=I,this._h[9]=A},r.prototype.finish=function(e,t){t===void 0&&(t=0);var i=new Uint16Array(10),n,s,o,a;if(this._leftover){for(a=this._leftover,this._buffer[a++]=1;a<16;a++)this._buffer[a]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(n=this._h[1]>>>13,this._h[1]&=8191,a=2;a<10;a++)this._h[a]+=n,n=this._h[a]>>>13,this._h[a]&=8191;for(this._h[0]+=n*5,n=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=n,n=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=n,i[0]=this._h[0]+5,n=i[0]>>>13,i[0]&=8191,a=1;a<10;a++)i[a]=this._h[a]+n,n=i[a]>>>13,i[a]&=8191;for(i[9]-=8192,s=(n^1)-1,a=0;a<10;a++)i[a]&=s;for(s=~s,a=0;a<10;a++)this._h[a]=this._h[a]&s|i[a];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,o=this._h[0]+this._pad[0],this._h[0]=o&65535,a=1;a<8;a++)o=(this._h[a]+this._pad[a]|0)+(o>>>16)|0,this._h[a]=o&65535;return e[t+0]=this._h[0]>>>0,e[t+1]=this._h[0]>>>8,e[t+2]=this._h[1]>>>0,e[t+3]=this._h[1]>>>8,e[t+4]=this._h[2]>>>0,e[t+5]=this._h[2]>>>8,e[t+6]=this._h[3]>>>0,e[t+7]=this._h[3]>>>8,e[t+8]=this._h[4]>>>0,e[t+9]=this._h[4]>>>8,e[t+10]=this._h[5]>>>0,e[t+11]=this._h[5]>>>8,e[t+12]=this._h[6]>>>0,e[t+13]=this._h[6]>>>8,e[t+14]=this._h[7]>>>0,e[t+15]=this._h[7]>>>8,this._finished=!0,this},r.prototype.update=function(e){var t=0,i=e.length,n;if(this._leftover){n=16-this._leftover,n>i&&(n=i);for(var s=0;s=16&&(n=i-i%16,this._blocks(e,t,n),t+=n,i-=n),i){for(var s=0;s{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});var vf=vb(),sE=xb(),fa=cr(),_b=Is(),oE=mf();Ni.KEY_LENGTH=32;Ni.NONCE_LENGTH=12;Ni.TAG_LENGTH=16;var Eb=new Uint8Array(16),aE=function(){function r(e){if(this.nonceLength=Ni.NONCE_LENGTH,this.tagLength=Ni.TAG_LENGTH,e.length!==Ni.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(e)}return r.prototype.seal=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var s=new Uint8Array(16);s.set(e,s.length-e.length);var o=new Uint8Array(32);vf.stream(this._key,s,o,4);var a=t.length+this.tagLength,f;if(n){if(n.length!==a)throw new Error("ChaCha20Poly1305: incorrect destination length");f=n}else f=new Uint8Array(a);return vf.streamXOR(this._key,s,t,f,4),this._authenticate(f.subarray(f.length-this.tagLength,f.length),o,f.subarray(0,f.length-this.tagLength),i),fa.wipe(s),f},r.prototype.open=function(e,t,i,n){if(e.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(t.length0&&s.update(Eb.subarray(n.length%16))),s.update(i),i.length%16>0&&s.update(Eb.subarray(i.length%16));var o=new Uint8Array(8);n&&_b.writeUint64LE(n.length,o),s.update(o),_b.writeUint64LE(i.length,o),s.update(o);for(var a=s.digest(),f=0;f{"use strict";Object.defineProperty(Ld,"__esModule",{value:!0});function cE(r){return typeof r.saveState<"u"&&typeof r.restoreState<"u"&&typeof r.cleanSavedState<"u"}Ld.isSerializableHash=cE});var Mb=J(ua=>{"use strict";Object.defineProperty(ua,"__esModule",{value:!0});var fi=Ib(),fE=mf(),uE=cr(),Ab=function(){function r(e,t){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var i=new Uint8Array(this.blockSize);t.length>this.blockSize?this._inner.update(t).finish(i).clean():i.set(t);for(var n=0;n{"use strict";Object.defineProperty(Fd,"__esModule",{value:!0});var Tb=Mb(),Pb=cr(),dE=function(){function r(e,t,i,n){i===void 0&&(i=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=n;var s=Tb.hmac(this._hash,i,t);this._hmac=new Tb.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return r.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},r.prototype.expand=function(e){for(var t=new Uint8Array(e),i=0;i{"use strict";Object.defineProperty(Qi,"__esModule",{value:!0});var wf=Is(),yf=cr();Qi.DIGEST_LENGTH=32;Qi.BLOCK_SIZE=64;var Nb=function(){function r(){this.digestLength=Qi.DIGEST_LENGTH,this.blockSize=Qi.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return r.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},r.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},r.prototype.clean=function(){yf.wipe(this._buffer),yf.wipe(this._temp),this.reset()},r.prototype.update=function(e,t){if(t===void 0&&(t=e.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var i=0;if(this._bytesHashed+=t,this._bufferLength>0){for(;this._bufferLength0;)this._buffer[this._bufferLength++]=e[i++],t--;this._bufferLength===this.blockSize&&(Ud(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(t>=this.blockSize&&(i=Ud(this._temp,this._state,e,i,t),t%=this.blockSize);t>0;)this._buffer[this._bufferLength++]=e[i++],t--;return this},r.prototype.finish=function(e){if(!this._finished){var t=this._bytesHashed,i=this._bufferLength,n=t/536870912|0,s=t<<3,o=t%64<56?64:128;this._buffer[i]=128;for(var a=i+1;a0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},r.prototype.restoreState=function(e){return this._state.set(e.state),this._bufferLength=e.bufferLength,e.buffer&&this._buffer.set(e.buffer),this._bytesHashed=e.bytesHashed,this._finished=!1,this},r.prototype.cleanSavedState=function(e){yf.wipe(e.state),e.buffer&&yf.wipe(e.buffer),e.bufferLength=0,e.bytesHashed=0},r}();Qi.SHA256=Nb;var lE=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function Ud(r,e,t,i,n){for(;n>=64;){for(var s=e[0],o=e[1],a=e[2],f=e[3],u=e[4],g=e[5],y=e[6],S=e[7],I=0;I<16;I++){var A=i+I*4;r[I]=wf.readUint32BE(t,A)}for(var I=16;I<64;I++){var P=r[I-2],O=(P>>>17|P<<15)^(P>>>19|P<<13)^P>>>10;P=r[I-15];var N=(P>>>7|P<<25)^(P>>>18|P<<14)^P>>>3;r[I]=(O+r[I-7]|0)+(N+r[I-16]|0)}for(var I=0;I<64;I++){var O=(((u>>>6|u<<26)^(u>>>11|u<<21)^(u>>>25|u<<7))+(u&g^~u&y)|0)+(S+(lE[I]+r[I]|0)|0)|0,N=((s>>>2|s<<30)^(s>>>13|s<<19)^(s>>>22|s<<10))+(s&o^s&a^o&a)|0;S=y,y=g,g=u,u=f+O|0,f=a,a=o,o=s,s=O+N|0}e[0]+=s,e[1]+=o,e[2]+=a,e[3]+=f,e[4]+=u,e[5]+=g,e[6]+=y,e[7]+=S,i+=64,n-=64}return i}function pE(r){var e=new Nb;e.update(r);var t=e.digest();return e.clean(),t}Qi.hash=pE});var Fb=J(it=>{"use strict";Object.defineProperty(it,"__esModule",{value:!0});it.sharedKey=it.generateKeyPair=it.generateKeyPairFromSeed=it.scalarMultBase=it.scalarMult=it.SHARED_KEY_LENGTH=it.SECRET_KEY_LENGTH=it.PUBLIC_KEY_LENGTH=void 0;var gE=$o(),mE=cr();it.PUBLIC_KEY_LENGTH=32;it.SECRET_KEY_LENGTH=32;it.SHARED_KEY_LENGTH=32;function ui(r){let e=new Float64Array(16);if(r)for(let t=0;t>16&1),t[o-1]&=65535;t[15]=i[15]-32767-(t[14]>>16&1);let s=t[15]>>16&1;t[14]&=65535,ha(i,t,1-s)}for(let n=0;n<16;n++)r[2*n]=i[n]&255,r[2*n+1]=i[n]>>8}function yE(r,e){for(let t=0;t<16;t++)r[t]=e[2*t]+(e[2*t+1]<<8);r[15]&=32767}function xf(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]+t[i]}function _f(r,e,t){for(let i=0;i<16;i++)r[i]=e[i]-t[i]}function Di(r,e,t){let i,n,s=0,o=0,a=0,f=0,u=0,g=0,y=0,S=0,I=0,A=0,P=0,O=0,N=0,U=0,k=0,B=0,j=0,V=0,L=0,C=0,W=0,R=0,l=0,w=0,p=0,c=0,d=0,b=0,x=0,v=0,h=0,_=t[0],M=t[1],m=t[2],T=t[3],z=t[4],E=t[5],D=t[6],F=t[7],q=t[8],K=t[9],Y=t[10],H=t[11],$=t[12],ee=t[13],G=t[14],X=t[15];i=e[0],s+=i*_,o+=i*M,a+=i*m,f+=i*T,u+=i*z,g+=i*E,y+=i*D,S+=i*F,I+=i*q,A+=i*K,P+=i*Y,O+=i*H,N+=i*$,U+=i*ee,k+=i*G,B+=i*X,i=e[1],o+=i*_,a+=i*M,f+=i*m,u+=i*T,g+=i*z,y+=i*E,S+=i*D,I+=i*F,A+=i*q,P+=i*K,O+=i*Y,N+=i*H,U+=i*$,k+=i*ee,B+=i*G,j+=i*X,i=e[2],a+=i*_,f+=i*M,u+=i*m,g+=i*T,y+=i*z,S+=i*E,I+=i*D,A+=i*F,P+=i*q,O+=i*K,N+=i*Y,U+=i*H,k+=i*$,B+=i*ee,j+=i*G,V+=i*X,i=e[3],f+=i*_,u+=i*M,g+=i*m,y+=i*T,S+=i*z,I+=i*E,A+=i*D,P+=i*F,O+=i*q,N+=i*K,U+=i*Y,k+=i*H,B+=i*$,j+=i*ee,V+=i*G,L+=i*X,i=e[4],u+=i*_,g+=i*M,y+=i*m,S+=i*T,I+=i*z,A+=i*E,P+=i*D,O+=i*F,N+=i*q,U+=i*K,k+=i*Y,B+=i*H,j+=i*$,V+=i*ee,L+=i*G,C+=i*X,i=e[5],g+=i*_,y+=i*M,S+=i*m,I+=i*T,A+=i*z,P+=i*E,O+=i*D,N+=i*F,U+=i*q,k+=i*K,B+=i*Y,j+=i*H,V+=i*$,L+=i*ee,C+=i*G,W+=i*X,i=e[6],y+=i*_,S+=i*M,I+=i*m,A+=i*T,P+=i*z,O+=i*E,N+=i*D,U+=i*F,k+=i*q,B+=i*K,j+=i*Y,V+=i*H,L+=i*$,C+=i*ee,W+=i*G,R+=i*X,i=e[7],S+=i*_,I+=i*M,A+=i*m,P+=i*T,O+=i*z,N+=i*E,U+=i*D,k+=i*F,B+=i*q,j+=i*K,V+=i*Y,L+=i*H,C+=i*$,W+=i*ee,R+=i*G,l+=i*X,i=e[8],I+=i*_,A+=i*M,P+=i*m,O+=i*T,N+=i*z,U+=i*E,k+=i*D,B+=i*F,j+=i*q,V+=i*K,L+=i*Y,C+=i*H,W+=i*$,R+=i*ee,l+=i*G,w+=i*X,i=e[9],A+=i*_,P+=i*M,O+=i*m,N+=i*T,U+=i*z,k+=i*E,B+=i*D,j+=i*F,V+=i*q,L+=i*K,C+=i*Y,W+=i*H,R+=i*$,l+=i*ee,w+=i*G,p+=i*X,i=e[10],P+=i*_,O+=i*M,N+=i*m,U+=i*T,k+=i*z,B+=i*E,j+=i*D,V+=i*F,L+=i*q,C+=i*K,W+=i*Y,R+=i*H,l+=i*$,w+=i*ee,p+=i*G,c+=i*X,i=e[11],O+=i*_,N+=i*M,U+=i*m,k+=i*T,B+=i*z,j+=i*E,V+=i*D,L+=i*F,C+=i*q,W+=i*K,R+=i*Y,l+=i*H,w+=i*$,p+=i*ee,c+=i*G,d+=i*X,i=e[12],N+=i*_,U+=i*M,k+=i*m,B+=i*T,j+=i*z,V+=i*E,L+=i*D,C+=i*F,W+=i*q,R+=i*K,l+=i*Y,w+=i*H,p+=i*$,c+=i*ee,d+=i*G,b+=i*X,i=e[13],U+=i*_,k+=i*M,B+=i*m,j+=i*T,V+=i*z,L+=i*E,C+=i*D,W+=i*F,R+=i*q,l+=i*K,w+=i*Y,p+=i*H,c+=i*$,d+=i*ee,b+=i*G,x+=i*X,i=e[14],k+=i*_,B+=i*M,j+=i*m,V+=i*T,L+=i*z,C+=i*E,W+=i*D,R+=i*F,l+=i*q,w+=i*K,p+=i*Y,c+=i*H,d+=i*$,b+=i*ee,x+=i*G,v+=i*X,i=e[15],B+=i*_,j+=i*M,V+=i*m,L+=i*T,C+=i*z,W+=i*E,R+=i*D,l+=i*F,w+=i*q,p+=i*K,c+=i*Y,d+=i*H,b+=i*$,x+=i*ee,v+=i*G,h+=i*X,s+=38*j,o+=38*V,a+=38*L,f+=38*C,u+=38*W,g+=38*R,y+=38*l,S+=38*w,I+=38*p,A+=38*c,P+=38*d,O+=38*b,N+=38*x,U+=38*v,k+=38*h,n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),n=1,i=s+n+65535,n=Math.floor(i/65536),s=i-n*65536,i=o+n+65535,n=Math.floor(i/65536),o=i-n*65536,i=a+n+65535,n=Math.floor(i/65536),a=i-n*65536,i=f+n+65535,n=Math.floor(i/65536),f=i-n*65536,i=u+n+65535,n=Math.floor(i/65536),u=i-n*65536,i=g+n+65535,n=Math.floor(i/65536),g=i-n*65536,i=y+n+65535,n=Math.floor(i/65536),y=i-n*65536,i=S+n+65535,n=Math.floor(i/65536),S=i-n*65536,i=I+n+65535,n=Math.floor(i/65536),I=i-n*65536,i=A+n+65535,n=Math.floor(i/65536),A=i-n*65536,i=P+n+65535,n=Math.floor(i/65536),P=i-n*65536,i=O+n+65535,n=Math.floor(i/65536),O=i-n*65536,i=N+n+65535,n=Math.floor(i/65536),N=i-n*65536,i=U+n+65535,n=Math.floor(i/65536),U=i-n*65536,i=k+n+65535,n=Math.floor(i/65536),k=i-n*65536,i=B+n+65535,n=Math.floor(i/65536),B=i-n*65536,s+=n-1+37*(n-1),r[0]=s,r[1]=o,r[2]=a,r[3]=f,r[4]=u,r[5]=g,r[6]=y,r[7]=S,r[8]=I,r[9]=A,r[10]=P,r[11]=O,r[12]=N,r[13]=U,r[14]=k,r[15]=B}function da(r,e){Di(r,e,e)}function wE(r,e){let t=ui();for(let i=0;i<16;i++)t[i]=e[i];for(let i=253;i>=0;i--)da(t,t),i!==2&&i!==4&&Di(t,t,e);for(let i=0;i<16;i++)r[i]=t[i]}function Bd(r,e){let t=new Uint8Array(32),i=new Float64Array(80),n=ui(),s=ui(),o=ui(),a=ui(),f=ui(),u=ui();for(let I=0;I<31;I++)t[I]=r[I];t[31]=r[31]&127|64,t[0]&=248,yE(i,e);for(let I=0;I<16;I++)s[I]=i[I];n[0]=a[0]=1;for(let I=254;I>=0;--I){let A=t[I>>>3]>>>(I&7)&1;ha(n,s,A),ha(o,a,A),xf(f,n,o),_f(n,n,o),xf(o,s,a),_f(s,s,a),da(a,f),da(u,n),Di(n,o,n),Di(o,s,f),xf(f,n,o),_f(n,n,o),da(s,n),_f(o,a,u),Di(n,o,bE),xf(n,n,a),Di(o,o,n),Di(n,a,u),Di(a,s,i),da(s,f),ha(n,s,A),ha(o,a,A)}for(let I=0;I<16;I++)i[I+16]=n[I],i[I+32]=o[I],i[I+48]=s[I],i[I+64]=a[I];let g=i.subarray(32),y=i.subarray(16);wE(g,g),Di(y,y,g);let S=new Uint8Array(32);return vE(S,y),S}it.scalarMult=Bd;function Ob(r){return Bd(r,Cb)}it.scalarMultBase=Ob;function Lb(r){if(r.length!==it.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${it.SECRET_KEY_LENGTH} bytes`);let e=new Uint8Array(r);return{publicKey:Ob(e),secretKey:e}}it.generateKeyPairFromSeed=Lb;function xE(r){let e=(0,gE.randomBytes)(32,r),t=Lb(e);return(0,mE.wipe)(e),t}it.generateKeyPair=xE;function _E(r,e,t=!1){if(r.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(e.length!==it.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");let i=Bd(r,e);if(t){let n=0;for(let s=0;s{EE.exports={name:"elliptic",version:"6.5.7",description:"EC cryptography",main:"lib/elliptic.js",files:["lib"],scripts:{lint:"eslint lib test","lint:fix":"npm run lint -- --fix",unit:"istanbul test _mocha --reporter=spec test/index.js",test:"npm run lint && npm run unit",version:"grunt dist && git add dist/"},repository:{type:"git",url:"git@github.com:indutny/elliptic"},keywords:["EC","Elliptic","curve","Cryptography"],author:"Fedor Indutny ",license:"MIT",bugs:{url:"https://github.com/indutny/elliptic/issues"},homepage:"https://github.com/indutny/elliptic",devDependencies:{brfs:"^2.0.2",coveralls:"^3.1.0",eslint:"^7.6.0",grunt:"^1.2.1","grunt-browserify":"^5.3.0","grunt-cli":"^1.3.2","grunt-contrib-connect":"^3.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^5.0.0","grunt-mocha-istanbul":"^5.0.2","grunt-saucelabs":"^9.0.1",istanbul:"^0.4.5",mocha:"^8.0.1"},dependencies:{"bn.js":"^4.11.9",brorand:"^1.1.0","hash.js":"^1.0.0","hmac-drbg":"^1.0.1",inherits:"^2.0.4","minimalistic-assert":"^1.0.1","minimalistic-crypto-utils":"^1.0.1"}}});var hi=J((qb,kd)=>{(function(r,e){"use strict";function t(R,l){if(!R)throw new Error(l||"Assertion failed")}function i(R,l){R.super_=l;var w=function(){};w.prototype=l.prototype,R.prototype=new w,R.prototype.constructor=R}function n(R,l,w){if(n.isBN(R))return R;this.negative=0,this.words=null,this.length=0,this.red=null,R!==null&&((l==="le"||l==="be")&&(w=l,l=10),this._init(R||0,l||10,w||"be"))}typeof r=="object"?r.exports=n:e.BN=n,n.BN=n,n.wordSize=26;var s;try{typeof window<"u"&&typeof window.Buffer<"u"?s=window.Buffer:s=ud().Buffer}catch{}n.isBN=function(l){return l instanceof n?!0:l!==null&&typeof l=="object"&&l.constructor.wordSize===n.wordSize&&Array.isArray(l.words)},n.max=function(l,w){return l.cmp(w)>0?l:w},n.min=function(l,w){return l.cmp(w)<0?l:w},n.prototype._init=function(l,w,p){if(typeof l=="number")return this._initNumber(l,w,p);if(typeof l=="object")return this._initArray(l,w,p);w==="hex"&&(w=16),t(w===(w|0)&&w>=2&&w<=36),l=l.toString().replace(/\s+/g,"");var c=0;l[0]==="-"&&(c++,this.negative=1),c=0;c-=3)b=l[c]|l[c-1]<<8|l[c-2]<<16,this.words[d]|=b<>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);else if(p==="le")for(c=0,d=0;c>>26-x&67108863,x+=24,x>=26&&(x-=26,d++);return this.strip()};function o(R,l){var w=R.charCodeAt(l);return w>=65&&w<=70?w-55:w>=97&&w<=102?w-87:w-48&15}function a(R,l,w){var p=o(R,w);return w-1>=l&&(p|=o(R,w-1)<<4),p}n.prototype._parseHex=function(l,w,p){this.length=Math.ceil((l.length-w)/6),this.words=new Array(this.length);for(var c=0;c=w;c-=2)x=a(l,w,c)<=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8;else{var v=l.length-w;for(c=v%2===0?w+1:w;c=18?(d-=18,b+=1,this.words[b]|=x>>>26):d+=8}this.strip()};function f(R,l,w,p){for(var c=0,d=Math.min(R.length,w),b=l;b=49?c+=x-49+10:x>=17?c+=x-17+10:c+=x}return c}n.prototype._parseBase=function(l,w,p){this.words=[0],this.length=1;for(var c=0,d=1;d<=67108863;d*=w)c++;c--,d=d/w|0;for(var b=l.length-p,x=b%c,v=Math.min(b,b-x)+p,h=0,_=p;_1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},n.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?""};var u=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],y=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];n.prototype.toString=function(l,w){l=l||10,w=w|0||1;var p;if(l===16||l==="hex"){p="";for(var c=0,d=0,b=0;b>>24-c&16777215,d!==0||b!==this.length-1?p=u[6-v.length]+v+p:p=v+p,c+=2,c>=26&&(c-=26,b--)}for(d!==0&&(p=d.toString(16)+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}if(l===(l|0)&&l>=2&&l<=36){var h=g[l],_=y[l];p="";var M=this.clone();for(M.negative=0;!M.isZero();){var m=M.modn(_).toString(l);M=M.idivn(_),M.isZero()?p=m+p:p=u[h-m.length]+m+p}for(this.isZero()&&(p="0"+p);p.length%w!==0;)p="0"+p;return this.negative!==0&&(p="-"+p),p}t(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var l=this.words[0];return this.length===2?l+=this.words[1]*67108864:this.length===3&&this.words[2]===1?l+=4503599627370496+this.words[1]*67108864:this.length>2&&t(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-l:l},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(l,w){return t(typeof s<"u"),this.toArrayLike(s,l,w)},n.prototype.toArray=function(l,w){return this.toArrayLike(Array,l,w)},n.prototype.toArrayLike=function(l,w,p){var c=this.byteLength(),d=p||Math.max(1,c);t(c<=d,"byte array longer than desired length"),t(d>0,"Requested array length <= 0"),this.strip();var b=w==="le",x=new l(d),v,h,_=this.clone();if(b){for(h=0;!_.isZero();h++)v=_.andln(255),_.iushrn(8),x[h]=v;for(;h=4096&&(p+=13,w>>>=13),w>=64&&(p+=7,w>>>=7),w>=8&&(p+=4,w>>>=4),w>=2&&(p+=2,w>>>=2),p+w},n.prototype._zeroBits=function(l){if(l===0)return 26;var w=l,p=0;return w&8191||(p+=13,w>>>=13),w&127||(p+=7,w>>>=7),w&15||(p+=4,w>>>=4),w&3||(p+=2,w>>>=2),w&1||p++,p},n.prototype.bitLength=function(){var l=this.words[this.length-1],w=this._countBits(l);return(this.length-1)*26+w};function S(R){for(var l=new Array(R.bitLength()),w=0;w>>c}return l}n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var l=0,w=0;wl.length?this.clone().ior(l):l.clone().ior(this)},n.prototype.uor=function(l){return this.length>l.length?this.clone().iuor(l):l.clone().iuor(this)},n.prototype.iuand=function(l){var w;this.length>l.length?w=l:w=this;for(var p=0;pl.length?this.clone().iand(l):l.clone().iand(this)},n.prototype.uand=function(l){return this.length>l.length?this.clone().iuand(l):l.clone().iuand(this)},n.prototype.iuxor=function(l){var w,p;this.length>l.length?(w=this,p=l):(w=l,p=this);for(var c=0;cl.length?this.clone().ixor(l):l.clone().ixor(this)},n.prototype.uxor=function(l){return this.length>l.length?this.clone().iuxor(l):l.clone().iuxor(this)},n.prototype.inotn=function(l){t(typeof l=="number"&&l>=0);var w=Math.ceil(l/26)|0,p=l%26;this._expand(w),p>0&&w--;for(var c=0;c0&&(this.words[c]=~this.words[c]&67108863>>26-p),this.strip()},n.prototype.notn=function(l){return this.clone().inotn(l)},n.prototype.setn=function(l,w){t(typeof l=="number"&&l>=0);var p=l/26|0,c=l%26;return this._expand(p+1),w?this.words[p]=this.words[p]|1<l.length?(p=this,c=l):(p=l,c=this);for(var d=0,b=0;b>>26;for(;d!==0&&b>>26;if(this.length=p.length,d!==0)this.words[this.length]=d,this.length++;else if(p!==this)for(;bl.length?this.clone().iadd(l):l.clone().iadd(this)},n.prototype.isub=function(l){if(l.negative!==0){l.negative=0;var w=this.iadd(l);return l.negative=1,w._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(l),this.negative=1,this._normSign();var p=this.cmp(l);if(p===0)return this.negative=0,this.length=1,this.words[0]=0,this;var c,d;p>0?(c=this,d=l):(c=l,d=this);for(var b=0,x=0;x>26,this.words[x]=w&67108863;for(;b!==0&&x>26,this.words[x]=w&67108863;if(b===0&&x>>26,M=v&67108863,m=Math.min(h,l.length-1),T=Math.max(0,h-R.length+1);T<=m;T++){var z=h-T|0;c=R.words[z]|0,d=l.words[T]|0,b=c*d+M,_+=b/67108864|0,M=b&67108863}w.words[h]=M|0,v=_|0}return v!==0?w.words[h]=v|0:w.length--,w.strip()}var A=function(l,w,p){var c=l.words,d=w.words,b=p.words,x=0,v,h,_,M=c[0]|0,m=M&8191,T=M>>>13,z=c[1]|0,E=z&8191,D=z>>>13,F=c[2]|0,q=F&8191,K=F>>>13,Y=c[3]|0,H=Y&8191,$=Y>>>13,ee=c[4]|0,G=ee&8191,X=ee>>>13,Ur=c[5]|0,se=Ur&8191,oe=Ur>>>13,qr=c[6]|0,ae=qr&8191,ce=qr>>>13,Br=c[7]|0,fe=Br&8191,ue=Br>>>13,kr=c[8]|0,he=kr&8191,de=kr>>>13,zr=c[9]|0,le=zr&8191,pe=zr>>>13,jr=d[0]|0,ge=jr&8191,me=jr>>>13,Kr=d[1]|0,be=Kr&8191,ve=Kr>>>13,Vr=d[2]|0,ye=Vr&8191,we=Vr>>>13,$r=d[3]|0,xe=$r&8191,_e=$r>>>13,Hr=d[4]|0,Ee=Hr&8191,Se=Hr>>>13,Gr=d[5]|0,Ie=Gr&8191,Ae=Gr>>>13,Wr=d[6]|0,Me=Wr&8191,Te=Wr>>>13,Jr=d[7]|0,Pe=Jr&8191,Re=Jr>>>13,Yr=d[8]|0,Ne=Yr&8191,De=Yr>>>13,Xr=d[9]|0,Ce=Xr&8191,Oe=Xr>>>13;p.negative=l.negative^w.negative,p.length=19,v=Math.imul(m,ge),h=Math.imul(m,me),h=h+Math.imul(T,ge)|0,_=Math.imul(T,me);var vr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(vr>>>26)|0,vr&=67108863,v=Math.imul(E,ge),h=Math.imul(E,me),h=h+Math.imul(D,ge)|0,_=Math.imul(D,me),v=v+Math.imul(m,be)|0,h=h+Math.imul(m,ve)|0,h=h+Math.imul(T,be)|0,_=_+Math.imul(T,ve)|0;var Ke=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ke>>>26)|0,Ke&=67108863,v=Math.imul(q,ge),h=Math.imul(q,me),h=h+Math.imul(K,ge)|0,_=Math.imul(K,me),v=v+Math.imul(E,be)|0,h=h+Math.imul(E,ve)|0,h=h+Math.imul(D,be)|0,_=_+Math.imul(D,ve)|0,v=v+Math.imul(m,ye)|0,h=h+Math.imul(m,we)|0,h=h+Math.imul(T,ye)|0,_=_+Math.imul(T,we)|0;var Ve=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Ve>>>26)|0,Ve&=67108863,v=Math.imul(H,ge),h=Math.imul(H,me),h=h+Math.imul($,ge)|0,_=Math.imul($,me),v=v+Math.imul(q,be)|0,h=h+Math.imul(q,ve)|0,h=h+Math.imul(K,be)|0,_=_+Math.imul(K,ve)|0,v=v+Math.imul(E,ye)|0,h=h+Math.imul(E,we)|0,h=h+Math.imul(D,ye)|0,_=_+Math.imul(D,we)|0,v=v+Math.imul(m,xe)|0,h=h+Math.imul(m,_e)|0,h=h+Math.imul(T,xe)|0,_=_+Math.imul(T,_e)|0;var tr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(tr>>>26)|0,tr&=67108863,v=Math.imul(G,ge),h=Math.imul(G,me),h=h+Math.imul(X,ge)|0,_=Math.imul(X,me),v=v+Math.imul(H,be)|0,h=h+Math.imul(H,ve)|0,h=h+Math.imul($,be)|0,_=_+Math.imul($,ve)|0,v=v+Math.imul(q,ye)|0,h=h+Math.imul(q,we)|0,h=h+Math.imul(K,ye)|0,_=_+Math.imul(K,we)|0,v=v+Math.imul(E,xe)|0,h=h+Math.imul(E,_e)|0,h=h+Math.imul(D,xe)|0,_=_+Math.imul(D,_e)|0,v=v+Math.imul(m,Ee)|0,h=h+Math.imul(m,Se)|0,h=h+Math.imul(T,Ee)|0,_=_+Math.imul(T,Se)|0;var rr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(rr>>>26)|0,rr&=67108863,v=Math.imul(se,ge),h=Math.imul(se,me),h=h+Math.imul(oe,ge)|0,_=Math.imul(oe,me),v=v+Math.imul(G,be)|0,h=h+Math.imul(G,ve)|0,h=h+Math.imul(X,be)|0,_=_+Math.imul(X,ve)|0,v=v+Math.imul(H,ye)|0,h=h+Math.imul(H,we)|0,h=h+Math.imul($,ye)|0,_=_+Math.imul($,we)|0,v=v+Math.imul(q,xe)|0,h=h+Math.imul(q,_e)|0,h=h+Math.imul(K,xe)|0,_=_+Math.imul(K,_e)|0,v=v+Math.imul(E,Ee)|0,h=h+Math.imul(E,Se)|0,h=h+Math.imul(D,Ee)|0,_=_+Math.imul(D,Se)|0,v=v+Math.imul(m,Ie)|0,h=h+Math.imul(m,Ae)|0,h=h+Math.imul(T,Ie)|0,_=_+Math.imul(T,Ae)|0;var ir=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(ir>>>26)|0,ir&=67108863,v=Math.imul(ae,ge),h=Math.imul(ae,me),h=h+Math.imul(ce,ge)|0,_=Math.imul(ce,me),v=v+Math.imul(se,be)|0,h=h+Math.imul(se,ve)|0,h=h+Math.imul(oe,be)|0,_=_+Math.imul(oe,ve)|0,v=v+Math.imul(G,ye)|0,h=h+Math.imul(G,we)|0,h=h+Math.imul(X,ye)|0,_=_+Math.imul(X,we)|0,v=v+Math.imul(H,xe)|0,h=h+Math.imul(H,_e)|0,h=h+Math.imul($,xe)|0,_=_+Math.imul($,_e)|0,v=v+Math.imul(q,Ee)|0,h=h+Math.imul(q,Se)|0,h=h+Math.imul(K,Ee)|0,_=_+Math.imul(K,Se)|0,v=v+Math.imul(E,Ie)|0,h=h+Math.imul(E,Ae)|0,h=h+Math.imul(D,Ie)|0,_=_+Math.imul(D,Ae)|0,v=v+Math.imul(m,Me)|0,h=h+Math.imul(m,Te)|0,h=h+Math.imul(T,Me)|0,_=_+Math.imul(T,Te)|0;var nr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(nr>>>26)|0,nr&=67108863,v=Math.imul(fe,ge),h=Math.imul(fe,me),h=h+Math.imul(ue,ge)|0,_=Math.imul(ue,me),v=v+Math.imul(ae,be)|0,h=h+Math.imul(ae,ve)|0,h=h+Math.imul(ce,be)|0,_=_+Math.imul(ce,ve)|0,v=v+Math.imul(se,ye)|0,h=h+Math.imul(se,we)|0,h=h+Math.imul(oe,ye)|0,_=_+Math.imul(oe,we)|0,v=v+Math.imul(G,xe)|0,h=h+Math.imul(G,_e)|0,h=h+Math.imul(X,xe)|0,_=_+Math.imul(X,_e)|0,v=v+Math.imul(H,Ee)|0,h=h+Math.imul(H,Se)|0,h=h+Math.imul($,Ee)|0,_=_+Math.imul($,Se)|0,v=v+Math.imul(q,Ie)|0,h=h+Math.imul(q,Ae)|0,h=h+Math.imul(K,Ie)|0,_=_+Math.imul(K,Ae)|0,v=v+Math.imul(E,Me)|0,h=h+Math.imul(E,Te)|0,h=h+Math.imul(D,Me)|0,_=_+Math.imul(D,Te)|0,v=v+Math.imul(m,Pe)|0,h=h+Math.imul(m,Re)|0,h=h+Math.imul(T,Pe)|0,_=_+Math.imul(T,Re)|0;var sr=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(sr>>>26)|0,sr&=67108863,v=Math.imul(he,ge),h=Math.imul(he,me),h=h+Math.imul(de,ge)|0,_=Math.imul(de,me),v=v+Math.imul(fe,be)|0,h=h+Math.imul(fe,ve)|0,h=h+Math.imul(ue,be)|0,_=_+Math.imul(ue,ve)|0,v=v+Math.imul(ae,ye)|0,h=h+Math.imul(ae,we)|0,h=h+Math.imul(ce,ye)|0,_=_+Math.imul(ce,we)|0,v=v+Math.imul(se,xe)|0,h=h+Math.imul(se,_e)|0,h=h+Math.imul(oe,xe)|0,_=_+Math.imul(oe,_e)|0,v=v+Math.imul(G,Ee)|0,h=h+Math.imul(G,Se)|0,h=h+Math.imul(X,Ee)|0,_=_+Math.imul(X,Se)|0,v=v+Math.imul(H,Ie)|0,h=h+Math.imul(H,Ae)|0,h=h+Math.imul($,Ie)|0,_=_+Math.imul($,Ae)|0,v=v+Math.imul(q,Me)|0,h=h+Math.imul(q,Te)|0,h=h+Math.imul(K,Me)|0,_=_+Math.imul(K,Te)|0,v=v+Math.imul(E,Pe)|0,h=h+Math.imul(E,Re)|0,h=h+Math.imul(D,Pe)|0,_=_+Math.imul(D,Re)|0,v=v+Math.imul(m,Ne)|0,h=h+Math.imul(m,De)|0,h=h+Math.imul(T,Ne)|0,_=_+Math.imul(T,De)|0;var _n=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(_n>>>26)|0,_n&=67108863,v=Math.imul(le,ge),h=Math.imul(le,me),h=h+Math.imul(pe,ge)|0,_=Math.imul(pe,me),v=v+Math.imul(he,be)|0,h=h+Math.imul(he,ve)|0,h=h+Math.imul(de,be)|0,_=_+Math.imul(de,ve)|0,v=v+Math.imul(fe,ye)|0,h=h+Math.imul(fe,we)|0,h=h+Math.imul(ue,ye)|0,_=_+Math.imul(ue,we)|0,v=v+Math.imul(ae,xe)|0,h=h+Math.imul(ae,_e)|0,h=h+Math.imul(ce,xe)|0,_=_+Math.imul(ce,_e)|0,v=v+Math.imul(se,Ee)|0,h=h+Math.imul(se,Se)|0,h=h+Math.imul(oe,Ee)|0,_=_+Math.imul(oe,Se)|0,v=v+Math.imul(G,Ie)|0,h=h+Math.imul(G,Ae)|0,h=h+Math.imul(X,Ie)|0,_=_+Math.imul(X,Ae)|0,v=v+Math.imul(H,Me)|0,h=h+Math.imul(H,Te)|0,h=h+Math.imul($,Me)|0,_=_+Math.imul($,Te)|0,v=v+Math.imul(q,Pe)|0,h=h+Math.imul(q,Re)|0,h=h+Math.imul(K,Pe)|0,_=_+Math.imul(K,Re)|0,v=v+Math.imul(E,Ne)|0,h=h+Math.imul(E,De)|0,h=h+Math.imul(D,Ne)|0,_=_+Math.imul(D,De)|0,v=v+Math.imul(m,Ce)|0,h=h+Math.imul(m,Oe)|0,h=h+Math.imul(T,Ce)|0,_=_+Math.imul(T,Oe)|0;var En=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(En>>>26)|0,En&=67108863,v=Math.imul(le,be),h=Math.imul(le,ve),h=h+Math.imul(pe,be)|0,_=Math.imul(pe,ve),v=v+Math.imul(he,ye)|0,h=h+Math.imul(he,we)|0,h=h+Math.imul(de,ye)|0,_=_+Math.imul(de,we)|0,v=v+Math.imul(fe,xe)|0,h=h+Math.imul(fe,_e)|0,h=h+Math.imul(ue,xe)|0,_=_+Math.imul(ue,_e)|0,v=v+Math.imul(ae,Ee)|0,h=h+Math.imul(ae,Se)|0,h=h+Math.imul(ce,Ee)|0,_=_+Math.imul(ce,Se)|0,v=v+Math.imul(se,Ie)|0,h=h+Math.imul(se,Ae)|0,h=h+Math.imul(oe,Ie)|0,_=_+Math.imul(oe,Ae)|0,v=v+Math.imul(G,Me)|0,h=h+Math.imul(G,Te)|0,h=h+Math.imul(X,Me)|0,_=_+Math.imul(X,Te)|0,v=v+Math.imul(H,Pe)|0,h=h+Math.imul(H,Re)|0,h=h+Math.imul($,Pe)|0,_=_+Math.imul($,Re)|0,v=v+Math.imul(q,Ne)|0,h=h+Math.imul(q,De)|0,h=h+Math.imul(K,Ne)|0,_=_+Math.imul(K,De)|0,v=v+Math.imul(E,Ce)|0,h=h+Math.imul(E,Oe)|0,h=h+Math.imul(D,Ce)|0,_=_+Math.imul(D,Oe)|0;var Sn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Sn>>>26)|0,Sn&=67108863,v=Math.imul(le,ye),h=Math.imul(le,we),h=h+Math.imul(pe,ye)|0,_=Math.imul(pe,we),v=v+Math.imul(he,xe)|0,h=h+Math.imul(he,_e)|0,h=h+Math.imul(de,xe)|0,_=_+Math.imul(de,_e)|0,v=v+Math.imul(fe,Ee)|0,h=h+Math.imul(fe,Se)|0,h=h+Math.imul(ue,Ee)|0,_=_+Math.imul(ue,Se)|0,v=v+Math.imul(ae,Ie)|0,h=h+Math.imul(ae,Ae)|0,h=h+Math.imul(ce,Ie)|0,_=_+Math.imul(ce,Ae)|0,v=v+Math.imul(se,Me)|0,h=h+Math.imul(se,Te)|0,h=h+Math.imul(oe,Me)|0,_=_+Math.imul(oe,Te)|0,v=v+Math.imul(G,Pe)|0,h=h+Math.imul(G,Re)|0,h=h+Math.imul(X,Pe)|0,_=_+Math.imul(X,Re)|0,v=v+Math.imul(H,Ne)|0,h=h+Math.imul(H,De)|0,h=h+Math.imul($,Ne)|0,_=_+Math.imul($,De)|0,v=v+Math.imul(q,Ce)|0,h=h+Math.imul(q,Oe)|0,h=h+Math.imul(K,Ce)|0,_=_+Math.imul(K,Oe)|0;var In=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(In>>>26)|0,In&=67108863,v=Math.imul(le,xe),h=Math.imul(le,_e),h=h+Math.imul(pe,xe)|0,_=Math.imul(pe,_e),v=v+Math.imul(he,Ee)|0,h=h+Math.imul(he,Se)|0,h=h+Math.imul(de,Ee)|0,_=_+Math.imul(de,Se)|0,v=v+Math.imul(fe,Ie)|0,h=h+Math.imul(fe,Ae)|0,h=h+Math.imul(ue,Ie)|0,_=_+Math.imul(ue,Ae)|0,v=v+Math.imul(ae,Me)|0,h=h+Math.imul(ae,Te)|0,h=h+Math.imul(ce,Me)|0,_=_+Math.imul(ce,Te)|0,v=v+Math.imul(se,Pe)|0,h=h+Math.imul(se,Re)|0,h=h+Math.imul(oe,Pe)|0,_=_+Math.imul(oe,Re)|0,v=v+Math.imul(G,Ne)|0,h=h+Math.imul(G,De)|0,h=h+Math.imul(X,Ne)|0,_=_+Math.imul(X,De)|0,v=v+Math.imul(H,Ce)|0,h=h+Math.imul(H,Oe)|0,h=h+Math.imul($,Ce)|0,_=_+Math.imul($,Oe)|0;var An=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(An>>>26)|0,An&=67108863,v=Math.imul(le,Ee),h=Math.imul(le,Se),h=h+Math.imul(pe,Ee)|0,_=Math.imul(pe,Se),v=v+Math.imul(he,Ie)|0,h=h+Math.imul(he,Ae)|0,h=h+Math.imul(de,Ie)|0,_=_+Math.imul(de,Ae)|0,v=v+Math.imul(fe,Me)|0,h=h+Math.imul(fe,Te)|0,h=h+Math.imul(ue,Me)|0,_=_+Math.imul(ue,Te)|0,v=v+Math.imul(ae,Pe)|0,h=h+Math.imul(ae,Re)|0,h=h+Math.imul(ce,Pe)|0,_=_+Math.imul(ce,Re)|0,v=v+Math.imul(se,Ne)|0,h=h+Math.imul(se,De)|0,h=h+Math.imul(oe,Ne)|0,_=_+Math.imul(oe,De)|0,v=v+Math.imul(G,Ce)|0,h=h+Math.imul(G,Oe)|0,h=h+Math.imul(X,Ce)|0,_=_+Math.imul(X,Oe)|0;var Mn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Mn>>>26)|0,Mn&=67108863,v=Math.imul(le,Ie),h=Math.imul(le,Ae),h=h+Math.imul(pe,Ie)|0,_=Math.imul(pe,Ae),v=v+Math.imul(he,Me)|0,h=h+Math.imul(he,Te)|0,h=h+Math.imul(de,Me)|0,_=_+Math.imul(de,Te)|0,v=v+Math.imul(fe,Pe)|0,h=h+Math.imul(fe,Re)|0,h=h+Math.imul(ue,Pe)|0,_=_+Math.imul(ue,Re)|0,v=v+Math.imul(ae,Ne)|0,h=h+Math.imul(ae,De)|0,h=h+Math.imul(ce,Ne)|0,_=_+Math.imul(ce,De)|0,v=v+Math.imul(se,Ce)|0,h=h+Math.imul(se,Oe)|0,h=h+Math.imul(oe,Ce)|0,_=_+Math.imul(oe,Oe)|0;var Tn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Tn>>>26)|0,Tn&=67108863,v=Math.imul(le,Me),h=Math.imul(le,Te),h=h+Math.imul(pe,Me)|0,_=Math.imul(pe,Te),v=v+Math.imul(he,Pe)|0,h=h+Math.imul(he,Re)|0,h=h+Math.imul(de,Pe)|0,_=_+Math.imul(de,Re)|0,v=v+Math.imul(fe,Ne)|0,h=h+Math.imul(fe,De)|0,h=h+Math.imul(ue,Ne)|0,_=_+Math.imul(ue,De)|0,v=v+Math.imul(ae,Ce)|0,h=h+Math.imul(ae,Oe)|0,h=h+Math.imul(ce,Ce)|0,_=_+Math.imul(ce,Oe)|0;var Pn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Pn>>>26)|0,Pn&=67108863,v=Math.imul(le,Pe),h=Math.imul(le,Re),h=h+Math.imul(pe,Pe)|0,_=Math.imul(pe,Re),v=v+Math.imul(he,Ne)|0,h=h+Math.imul(he,De)|0,h=h+Math.imul(de,Ne)|0,_=_+Math.imul(de,De)|0,v=v+Math.imul(fe,Ce)|0,h=h+Math.imul(fe,Oe)|0,h=h+Math.imul(ue,Ce)|0,_=_+Math.imul(ue,Oe)|0;var Rn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Rn>>>26)|0,Rn&=67108863,v=Math.imul(le,Ne),h=Math.imul(le,De),h=h+Math.imul(pe,Ne)|0,_=Math.imul(pe,De),v=v+Math.imul(he,Ce)|0,h=h+Math.imul(he,Oe)|0,h=h+Math.imul(de,Ce)|0,_=_+Math.imul(de,Oe)|0;var Nn=(x+v|0)+((h&8191)<<13)|0;x=(_+(h>>>13)|0)+(Nn>>>26)|0,Nn&=67108863,v=Math.imul(le,Ce),h=Math.imul(le,Oe),h=h+Math.imul(pe,Ce)|0,_=Math.imul(pe,Oe);var Dn=(x+v|0)+((h&8191)<<13)|0;return x=(_+(h>>>13)|0)+(Dn>>>26)|0,Dn&=67108863,b[0]=vr,b[1]=Ke,b[2]=Ve,b[3]=tr,b[4]=rr,b[5]=ir,b[6]=nr,b[7]=sr,b[8]=_n,b[9]=En,b[10]=Sn,b[11]=In,b[12]=An,b[13]=Mn,b[14]=Tn,b[15]=Pn,b[16]=Rn,b[17]=Nn,b[18]=Dn,x!==0&&(b[19]=x,p.length++),p};Math.imul||(A=I);function P(R,l,w){w.negative=l.negative^R.negative,w.length=R.length+l.length;for(var p=0,c=0,d=0;d>>26)|0,c+=b>>>26,b&=67108863}w.words[d]=x,p=b,b=c}return p!==0?w.words[d]=p:w.length--,w.strip()}function O(R,l,w){var p=new N;return p.mulp(R,l,w)}n.prototype.mulTo=function(l,w){var p,c=this.length+l.length;return this.length===10&&l.length===10?p=A(this,l,w):c<63?p=I(this,l,w):c<1024?p=P(this,l,w):p=O(this,l,w),p};function N(R,l){this.x=R,this.y=l}N.prototype.makeRBT=function(l){for(var w=new Array(l),p=n.prototype._countBits(l)-1,c=0;c>=1;return c},N.prototype.permute=function(l,w,p,c,d,b){for(var x=0;x>>1)d++;return 1<>>13,p[2*b+1]=d&8191,d=d>>>13;for(b=2*w;b>=26,w+=c/67108864|0,w+=d>>>26,this.words[p]=d&67108863}return w!==0&&(this.words[p]=w,this.length++),this},n.prototype.muln=function(l){return this.clone().imuln(l)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(l){var w=S(l);if(w.length===0)return new n(1);for(var p=this,c=0;c=0);var w=l%26,p=(l-w)/26,c=67108863>>>26-w<<26-w,d;if(w!==0){var b=0;for(d=0;d>>26-w}b&&(this.words[d]=b,this.length++)}if(p!==0){for(d=this.length-1;d>=0;d--)this.words[d+p]=this.words[d];for(d=0;d=0);var c;w?c=(w-w%26)/26:c=0;var d=l%26,b=Math.min((l-d)/26,this.length),x=67108863^67108863>>>d<b)for(this.length-=b,h=0;h=0&&(_!==0||h>=c);h--){var M=this.words[h]|0;this.words[h]=_<<26-d|M>>>d,_=M&x}return v&&_!==0&&(v.words[v.length++]=_),this.length===0&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(l,w,p){return t(this.negative===0),this.iushrn(l,w,p)},n.prototype.shln=function(l){return this.clone().ishln(l)},n.prototype.ushln=function(l){return this.clone().iushln(l)},n.prototype.shrn=function(l){return this.clone().ishrn(l)},n.prototype.ushrn=function(l){return this.clone().iushrn(l)},n.prototype.testn=function(l){t(typeof l=="number"&&l>=0);var w=l%26,p=(l-w)/26,c=1<=0);var w=l%26,p=(l-w)/26;if(t(this.negative===0,"imaskn works only with positive numbers"),this.length<=p)return this;if(w!==0&&p++,this.length=Math.min(p,this.length),w!==0){var c=67108863^67108863>>>w<=67108864;w++)this.words[w]-=67108864,w===this.length-1?this.words[w+1]=1:this.words[w+1]++;return this.length=Math.max(this.length,w+1),this},n.prototype.isubn=function(l){if(t(typeof l=="number"),t(l<67108864),l<0)return this.iaddn(-l);if(this.negative!==0)return this.negative=0,this.iaddn(l),this.negative=1,this;if(this.words[0]-=l,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var w=0;w>26)-(v/67108864|0),this.words[d+p]=b&67108863}for(;d>26,this.words[d+p]=b&67108863;if(x===0)return this.strip();for(t(x===-1),x=0,d=0;d>26,this.words[d]=b&67108863;return this.negative=1,this.strip()},n.prototype._wordDiv=function(l,w){var p=this.length-l.length,c=this.clone(),d=l,b=d.words[d.length-1]|0,x=this._countBits(b);p=26-x,p!==0&&(d=d.ushln(p),c.iushln(p),b=d.words[d.length-1]|0);var v=c.length-d.length,h;if(w!=="mod"){h=new n(null),h.length=v+1,h.words=new Array(h.length);for(var _=0;_=0;m--){var T=(c.words[d.length+m]|0)*67108864+(c.words[d.length+m-1]|0);for(T=Math.min(T/b|0,67108863),c._ishlnsubmul(d,T,m);c.negative!==0;)T--,c.negative=0,c._ishlnsubmul(d,1,m),c.isZero()||(c.negative^=1);h&&(h.words[m]=T)}return h&&h.strip(),c.strip(),w!=="div"&&p!==0&&c.iushrn(p),{div:h||null,mod:c}},n.prototype.divmod=function(l,w,p){if(t(!l.isZero()),this.isZero())return{div:new n(0),mod:new n(0)};var c,d,b;return this.negative!==0&&l.negative===0?(b=this.neg().divmod(l,w),w!=="mod"&&(c=b.div.neg()),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.iadd(l)),{div:c,mod:d}):this.negative===0&&l.negative!==0?(b=this.divmod(l.neg(),w),w!=="mod"&&(c=b.div.neg()),{div:c,mod:b.mod}):this.negative&l.negative?(b=this.neg().divmod(l.neg(),w),w!=="div"&&(d=b.mod.neg(),p&&d.negative!==0&&d.isub(l)),{div:b.div,mod:d}):l.length>this.length||this.cmp(l)<0?{div:new n(0),mod:this}:l.length===1?w==="div"?{div:this.divn(l.words[0]),mod:null}:w==="mod"?{div:null,mod:new n(this.modn(l.words[0]))}:{div:this.divn(l.words[0]),mod:new n(this.modn(l.words[0]))}:this._wordDiv(l,w)},n.prototype.div=function(l){return this.divmod(l,"div",!1).div},n.prototype.mod=function(l){return this.divmod(l,"mod",!1).mod},n.prototype.umod=function(l){return this.divmod(l,"mod",!0).mod},n.prototype.divRound=function(l){var w=this.divmod(l);if(w.mod.isZero())return w.div;var p=w.div.negative!==0?w.mod.isub(l):w.mod,c=l.ushrn(1),d=l.andln(1),b=p.cmp(c);return b<0||d===1&&b===0?w.div:w.div.negative!==0?w.div.isubn(1):w.div.iaddn(1)},n.prototype.modn=function(l){t(l<=67108863);for(var w=(1<<26)%l,p=0,c=this.length-1;c>=0;c--)p=(w*p+(this.words[c]|0))%l;return p},n.prototype.idivn=function(l){t(l<=67108863);for(var w=0,p=this.length-1;p>=0;p--){var c=(this.words[p]|0)+w*67108864;this.words[p]=c/l|0,w=c%l}return this.strip()},n.prototype.divn=function(l){return this.clone().idivn(l)},n.prototype.egcd=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=new n(0),x=new n(1),v=0;w.isEven()&&p.isEven();)w.iushrn(1),p.iushrn(1),++v;for(var h=p.clone(),_=w.clone();!w.isZero();){for(var M=0,m=1;!(w.words[0]&m)&&M<26;++M,m<<=1);if(M>0)for(w.iushrn(M);M-- >0;)(c.isOdd()||d.isOdd())&&(c.iadd(h),d.isub(_)),c.iushrn(1),d.iushrn(1);for(var T=0,z=1;!(p.words[0]&z)&&T<26;++T,z<<=1);if(T>0)for(p.iushrn(T);T-- >0;)(b.isOdd()||x.isOdd())&&(b.iadd(h),x.isub(_)),b.iushrn(1),x.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(b),d.isub(x)):(p.isub(w),b.isub(c),x.isub(d))}return{a:b,b:x,gcd:p.iushln(v)}},n.prototype._invmp=function(l){t(l.negative===0),t(!l.isZero());var w=this,p=l.clone();w.negative!==0?w=w.umod(l):w=w.clone();for(var c=new n(1),d=new n(0),b=p.clone();w.cmpn(1)>0&&p.cmpn(1)>0;){for(var x=0,v=1;!(w.words[0]&v)&&x<26;++x,v<<=1);if(x>0)for(w.iushrn(x);x-- >0;)c.isOdd()&&c.iadd(b),c.iushrn(1);for(var h=0,_=1;!(p.words[0]&_)&&h<26;++h,_<<=1);if(h>0)for(p.iushrn(h);h-- >0;)d.isOdd()&&d.iadd(b),d.iushrn(1);w.cmp(p)>=0?(w.isub(p),c.isub(d)):(p.isub(w),d.isub(c))}var M;return w.cmpn(1)===0?M=c:M=d,M.cmpn(0)<0&&M.iadd(l),M},n.prototype.gcd=function(l){if(this.isZero())return l.abs();if(l.isZero())return this.abs();var w=this.clone(),p=l.clone();w.negative=0,p.negative=0;for(var c=0;w.isEven()&&p.isEven();c++)w.iushrn(1),p.iushrn(1);do{for(;w.isEven();)w.iushrn(1);for(;p.isEven();)p.iushrn(1);var d=w.cmp(p);if(d<0){var b=w;w=p,p=b}else if(d===0||p.cmpn(1)===0)break;w.isub(p)}while(!0);return p.iushln(c)},n.prototype.invm=function(l){return this.egcd(l).a.umod(l)},n.prototype.isEven=function(){return(this.words[0]&1)===0},n.prototype.isOdd=function(){return(this.words[0]&1)===1},n.prototype.andln=function(l){return this.words[0]&l},n.prototype.bincn=function(l){t(typeof l=="number");var w=l%26,p=(l-w)/26,c=1<>>26,x&=67108863,this.words[b]=x}return d!==0&&(this.words[b]=d,this.length++),this},n.prototype.isZero=function(){return this.length===1&&this.words[0]===0},n.prototype.cmpn=function(l){var w=l<0;if(this.negative!==0&&!w)return-1;if(this.negative===0&&w)return 1;this.strip();var p;if(this.length>1)p=1;else{w&&(l=-l),t(l<=67108863,"Number is too big");var c=this.words[0]|0;p=c===l?0:cl.length)return 1;if(this.length=0;p--){var c=this.words[p]|0,d=l.words[p]|0;if(c!==d){cd&&(w=1);break}}return w},n.prototype.gtn=function(l){return this.cmpn(l)===1},n.prototype.gt=function(l){return this.cmp(l)===1},n.prototype.gten=function(l){return this.cmpn(l)>=0},n.prototype.gte=function(l){return this.cmp(l)>=0},n.prototype.ltn=function(l){return this.cmpn(l)===-1},n.prototype.lt=function(l){return this.cmp(l)===-1},n.prototype.lten=function(l){return this.cmpn(l)<=0},n.prototype.lte=function(l){return this.cmp(l)<=0},n.prototype.eqn=function(l){return this.cmpn(l)===0},n.prototype.eq=function(l){return this.cmp(l)===0},n.red=function(l){return new C(l)},n.prototype.toRed=function(l){return t(!this.red,"Already a number in reduction context"),t(this.negative===0,"red works only with positives"),l.convertTo(this)._forceRed(l)},n.prototype.fromRed=function(){return t(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(l){return this.red=l,this},n.prototype.forceRed=function(l){return t(!this.red,"Already a number in reduction context"),this._forceRed(l)},n.prototype.redAdd=function(l){return t(this.red,"redAdd works only with red numbers"),this.red.add(this,l)},n.prototype.redIAdd=function(l){return t(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,l)},n.prototype.redSub=function(l){return t(this.red,"redSub works only with red numbers"),this.red.sub(this,l)},n.prototype.redISub=function(l){return t(this.red,"redISub works only with red numbers"),this.red.isub(this,l)},n.prototype.redShl=function(l){return t(this.red,"redShl works only with red numbers"),this.red.shl(this,l)},n.prototype.redMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.mul(this,l)},n.prototype.redIMul=function(l){return t(this.red,"redMul works only with red numbers"),this.red._verify2(this,l),this.red.imul(this,l)},n.prototype.redSqr=function(){return t(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return t(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return t(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return t(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return t(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(l){return t(this.red&&!l.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,l)};var U={k256:null,p224:null,p192:null,p25519:null};function k(R,l){this.name=R,this.p=new n(l,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}k.prototype._tmp=function(){var l=new n(null);return l.words=new Array(Math.ceil(this.n/13)),l},k.prototype.ireduce=function(l){var w=l,p;do this.split(w,this.tmp),w=this.imulK(w),w=w.iadd(this.tmp),p=w.bitLength();while(p>this.n);var c=p0?w.isub(this.p):w.strip!==void 0?w.strip():w._strip(),w},k.prototype.split=function(l,w){l.iushrn(this.n,0,w)},k.prototype.imulK=function(l){return l.imul(this.k)};function B(){k.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(B,k),B.prototype.split=function(l,w){for(var p=4194303,c=Math.min(l.length,9),d=0;d>>22,b=x}b>>>=22,l.words[d-10]=b,b===0&&l.length>10?l.length-=10:l.length-=9},B.prototype.imulK=function(l){l.words[l.length]=0,l.words[l.length+1]=0,l.length+=2;for(var w=0,p=0;p>>=26,l.words[p]=d,w=c}return w!==0&&(l.words[l.length++]=w),l},n._prime=function(l){if(U[l])return U[l];var w;if(l==="k256")w=new B;else if(l==="p224")w=new j;else if(l==="p192")w=new V;else if(l==="p25519")w=new L;else throw new Error("Unknown prime "+l);return U[l]=w,w};function C(R){if(typeof R=="string"){var l=n._prime(R);this.m=l.p,this.prime=l}else t(R.gtn(1),"modulus must be greater than 1"),this.m=R,this.prime=null}C.prototype._verify1=function(l){t(l.negative===0,"red works only with positives"),t(l.red,"red works only with red numbers")},C.prototype._verify2=function(l,w){t((l.negative|w.negative)===0,"red works only with positives"),t(l.red&&l.red===w.red,"red works only with red numbers")},C.prototype.imod=function(l){return this.prime?this.prime.ireduce(l)._forceRed(this):l.umod(this.m)._forceRed(this)},C.prototype.neg=function(l){return l.isZero()?l.clone():this.m.sub(l)._forceRed(this)},C.prototype.add=function(l,w){this._verify2(l,w);var p=l.add(w);return p.cmp(this.m)>=0&&p.isub(this.m),p._forceRed(this)},C.prototype.iadd=function(l,w){this._verify2(l,w);var p=l.iadd(w);return p.cmp(this.m)>=0&&p.isub(this.m),p},C.prototype.sub=function(l,w){this._verify2(l,w);var p=l.sub(w);return p.cmpn(0)<0&&p.iadd(this.m),p._forceRed(this)},C.prototype.isub=function(l,w){this._verify2(l,w);var p=l.isub(w);return p.cmpn(0)<0&&p.iadd(this.m),p},C.prototype.shl=function(l,w){return this._verify1(l),this.imod(l.ushln(w))},C.prototype.imul=function(l,w){return this._verify2(l,w),this.imod(l.imul(w))},C.prototype.mul=function(l,w){return this._verify2(l,w),this.imod(l.mul(w))},C.prototype.isqr=function(l){return this.imul(l,l.clone())},C.prototype.sqr=function(l){return this.mul(l,l)},C.prototype.sqrt=function(l){if(l.isZero())return l.clone();var w=this.m.andln(3);if(t(w%2===1),w===3){var p=this.m.add(new n(1)).iushrn(2);return this.pow(l,p)}for(var c=this.m.subn(1),d=0;!c.isZero()&&c.andln(1)===0;)d++,c.iushrn(1);t(!c.isZero());var b=new n(1).toRed(this),x=b.redNeg(),v=this.m.subn(1).iushrn(1),h=this.m.bitLength();for(h=new n(2*h*h).toRed(this);this.pow(h,v).cmp(x)!==0;)h.redIAdd(x);for(var _=this.pow(h,c),M=this.pow(l,c.addn(1).iushrn(1)),m=this.pow(l,c),T=d;m.cmp(b)!==0;){for(var z=m,E=0;z.cmp(b)!==0;E++)z=z.redSqr();t(E=0;d--){for(var _=w.words[d],M=h-1;M>=0;M--){var m=_>>M&1;if(b!==c[0]&&(b=this.sqr(b)),m===0&&x===0){v=0;continue}x<<=1,x|=m,v++,!(v!==p&&(d!==0||M!==0))&&(b=this.mul(b,c[x]),v=0,x=0)}h=26}return b},C.prototype.convertTo=function(l){var w=l.umod(this.m);return w===l?w.clone():w},C.prototype.convertFrom=function(l){var w=l.clone();return w.red=null,w},n.mont=function(l){return new W(l)};function W(R){C.call(this,R),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,C),W.prototype.convertTo=function(l){return this.imod(l.ushln(this.shift))},W.prototype.convertFrom=function(l){var w=this.imod(l.mul(this.rinv));return w.red=null,w},W.prototype.imul=function(l,w){if(l.isZero()||w.isZero())return l.words[0]=0,l.length=1,l;var p=l.imul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.mul=function(l,w){if(l.isZero()||w.isZero())return new n(0)._forceRed(this);var p=l.mul(w),c=p.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),d=p.isub(c).iushrn(this.shift),b=d;return d.cmp(this.m)>=0?b=d.isub(this.m):d.cmpn(0)<0&&(b=d.iadd(this.m)),b._forceRed(this)},W.prototype.invm=function(l){var w=this.imod(l._invmp(this.m).mul(this.r2));return w._forceRed(this)}})(typeof kd>"u"||kd,qb)});var zd=J(zb=>{"use strict";var Ef=zb;function SE(r,e){if(Array.isArray(r))return r.slice();if(!r)return[];var t=[];if(typeof r!="string"){for(var i=0;i>8,o=n&255;s?t.push(s,o):t.push(o)}return t}Ef.toArray=SE;function Bb(r){return r.length===1?"0"+r:r}Ef.zero2=Bb;function kb(r){for(var e="",t=0;t{"use strict";var Pr=jb,IE=hi(),AE=Wi(),Sf=zd();Pr.assert=AE;Pr.toArray=Sf.toArray;Pr.zero2=Sf.zero2;Pr.toHex=Sf.toHex;Pr.encode=Sf.encode;function ME(r,e,t){var i=new Array(Math.max(r.bitLength(),t)+1),n;for(n=0;n(s>>1)-1?a=(s>>1)-f:a=f,o.isubn(a)):a=0,i[n]=a,o.iushrn(1)}return i}Pr.getNAF=ME;function TE(r,e){var t=[[],[]];r=r.clone(),e=e.clone();for(var i=0,n=0,s;r.cmpn(-i)>0||e.cmpn(-n)>0;){var o=r.andln(3)+i&3,a=e.andln(3)+n&3;o===3&&(o=-1),a===3&&(a=-1);var f;o&1?(s=r.andln(7)+i&7,(s===3||s===5)&&a===2?f=-o:f=o):f=0,t[0].push(f);var u;a&1?(s=e.andln(7)+n&7,(s===3||s===5)&&o===2?u=-a:u=a):u=0,t[1].push(u),2*i===f+1&&(i=1-i),2*n===u+1&&(n=1-n),r.iushrn(1),e.iushrn(1)}return t}Pr.getJSF=TE;function PE(r,e,t){var i="_"+e;r.prototype[e]=function(){return this[i]!==void 0?this[i]:this[i]=t.call(this)}}Pr.cachedProperty=PE;function RE(r){return typeof r=="string"?Pr.toArray(r,"hex"):r}Pr.parseBytes=RE;function NE(r){return new IE(r,"hex","le")}Pr.intFromLE=NE});var $d=J((wC,Vd)=>{var jd;Vd.exports=function(e){return jd||(jd=new Zi(null)),jd.generate(e)};function Zi(r){this.rand=r}Vd.exports.Rand=Zi;Zi.prototype.generate=function(e){return this._rand(e)};Zi.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i{"use strict";var Wn=hi(),la=Yt(),If=la.getNAF,DE=la.getJSF,Af=la.assert;function en(r,e){this.type=r,this.p=new Wn(e.p,16),this.red=e.prime?Wn.red(e.prime):Wn.mont(this.p),this.zero=new Wn(0).toRed(this.red),this.one=new Wn(1).toRed(this.red),this.two=new Wn(2).toRed(this.red),this.n=e.n&&new Wn(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}Kb.exports=en;en.prototype.point=function(){throw new Error("Not implemented")};en.prototype.validate=function(){throw new Error("Not implemented")};en.prototype._fixedNafMul=function(e,t){Af(e.precomputed);var i=e._getDoubles(),n=If(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];Af(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};en.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,P=g;if(o[A]!==1||o[P]!==1){f[A]=If(i[A],o[A],this._bitLength),f[P]=If(i[P],o[P],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[P].length,u);continue}var O=[t[A],null,null,t[P]];t[A].y.cmp(t[P].y)===0?(O[1]=t[A].add(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg())):t[A].y.cmp(t[P].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].add(t[P].neg())):(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=DE(i[A],i[P]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[P]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var C=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};dr.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s{"use strict";var CE=Yt(),nt=hi(),Hd=sa(),Gs=pa(),OE=CE.assert;function lr(r){Gs.call(this,"short",r),this.a=new nt(r.a,16).toRed(this.red),this.b=new nt(r.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=this.a.fromRed().cmpn(0)===0,this.threeA=this.a.fromRed().sub(this.p).cmpn(-3)===0,this.endo=this._getEndomorphism(r),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}Hd(lr,Gs);Vb.exports=lr;lr.prototype._getEndomorphism=function(e){if(!(!this.zeroA||!this.g||!this.n||this.p.modn(3)!==1)){var t,i;if(e.beta)t=new nt(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=n[0].cmp(n[1])<0?n[0]:n[1],t=t.toRed(this.red)}if(e.lambda)i=new nt(e.lambda,16);else{var s=this._getEndoRoots(this.n);this.g.mul(s[0]).x.cmp(this.g.x.redMul(t))===0?i=s[0]:(i=s[1],OE(this.g.mul(i).x.cmp(this.g.x.redMul(t))===0))}var o;return e.basis?o=e.basis.map(function(a){return{a:new nt(a.a,16),b:new nt(a.b,16)}}):o=this._getEndoBasis(i),{beta:t,lambda:i,basis:o}}};lr.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:nt.mont(e),i=new nt(2).toRed(t).redInvm(),n=i.redNeg(),s=new nt(3).toRed(t).redNeg().redSqrt().redMul(i),o=n.redAdd(s).fromRed(),a=n.redSub(s).fromRed();return[o,a]};lr.prototype._getEndoBasis=function(e){for(var t=this.n.ushrn(Math.floor(this.n.bitLength()/2)),i=e,n=this.n.clone(),s=new nt(1),o=new nt(0),a=new nt(0),f=new nt(1),u,g,y,S,I,A,P,O=0,N,U;i.cmpn(0)!==0;){var k=n.div(i);N=n.sub(k.mul(i)),U=a.sub(k.mul(s));var B=f.sub(k.mul(o));if(!y&&N.cmp(t)<0)u=P.neg(),g=s,y=N.neg(),S=U;else if(y&&++O===2)break;P=N,n=i,i=N,a=s,s=U,f=o,o=B}I=N.neg(),A=U;var j=y.sqr().add(S.sqr()),V=I.sqr().add(A.sqr());return V.cmp(j)>=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};lr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};lr.prototype.pointFromX=function(e,t){e=new nt(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};lr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};lr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};gt.prototype.isInfinity=function(){return this.inf};gt.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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};gt.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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),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)};gt.prototype.getX=function(){return this.x.fromRed()};gt.prototype.getY=function(){return this.y.fromRed()};gt.prototype.mul=function(e){return e=new nt(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)};gt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};gt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};gt.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)};gt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};gt.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 Et(r,e,t,i){Gs.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new nt(0)):(this.x=new nt(e,16),this.y=new nt(t,16),this.z=new nt(i,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}Hd(Et,Gs.BasePoint);lr.prototype.jpoint=function(e,t,i){return new Et(this,e,t,i)};Et.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};Et.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};Et.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,P)};Et.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};Et.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};Et.prototype.inspect=function(){return this.isInfinity()?"":""};Et.prototype.isInfinity=function(){return this.z.cmpn(0)===0}});var Wb=J((EC,Gb)=>{"use strict";var Ws=hi(),Hb=sa(),Mf=pa(),LE=Yt();function Js(r){Mf.call(this,"mont",r),this.a=new Ws(r.a,16).toRed(this.red),this.b=new Ws(r.b,16).toRed(this.red),this.i4=new Ws(4).toRed(this.red).redInvm(),this.two=new Ws(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}Hb(Js,Mf);Gb.exports=Js;Js.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),n=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t),s=n.redSqrt();return s.redSqr().cmp(n)===0};function mt(r,e,t){Mf.BasePoint.call(this,r,"projective"),e===null&&t===null?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new Ws(e,16),this.z=new Ws(t,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}Hb(mt,Mf.BasePoint);Js.prototype.decodePoint=function(e,t){return this.point(LE.toArray(e,t),1)};Js.prototype.point=function(e,t){return new mt(this,e,t)};Js.prototype.pointFromJSON=function(e){return mt.fromJSON(this,e)};mt.prototype.precompute=function(){};mt.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())};mt.fromJSON=function(e,t){return new mt(e,t[0],t[1]||e.one)};mt.prototype.inspect=function(){return this.isInfinity()?"":""};mt.prototype.isInfinity=function(){return this.z.cmpn(0)===0};mt.prototype.dbl=function(){var e=this.x.redAdd(this.z),t=e.redSqr(),i=this.x.redSub(this.z),n=i.redSqr(),s=t.redSub(n),o=t.redMul(n),a=s.redMul(n.redAdd(this.curve.a24.redMul(s)));return this.curve.point(o,a)};mt.prototype.add=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),n=this.x.redSub(this.z),s=e.x.redAdd(e.z),o=e.x.redSub(e.z),a=o.redMul(i),f=s.redMul(n),u=t.z.redMul(a.redAdd(f).redSqr()),g=t.x.redMul(a.redISub(f).redSqr());return this.curve.point(u,g)};mt.prototype.mul=function(e){for(var t=e.clone(),i=this,n=this.curve.point(null,null),s=this,o=[];t.cmpn(0)!==0;t.iushrn(1))o.push(t.andln(1));for(var a=o.length-1;a>=0;a--)o[a]===0?(i=i.diffAdd(n,s),n=n.dbl()):(n=i.diffAdd(n,s),i=i.dbl());return n};mt.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")};mt.prototype.eq=function(e){return this.getX().cmp(e.getX())===0};mt.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this};mt.prototype.getX=function(){return this.normalize(),this.x.fromRed()}});var Xb=J((SC,Yb)=>{"use strict";var FE=Yt(),Ci=hi(),Jb=sa(),Tf=pa(),UE=FE.assert;function di(r){this.twisted=(r.a|0)!==1,this.mOneA=this.twisted&&(r.a|0)===-1,this.extended=this.mOneA,Tf.call(this,"edwards",r),this.a=new Ci(r.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new Ci(r.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new Ci(r.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),UE(!this.twisted||this.c.fromRed().cmpn(1)===0),this.oneC=(r.c|0)===1}Jb(di,Tf);Yb.exports=di;di.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)};di.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)};di.prototype.jpoint=function(e,t,i,n){return this.point(e,t,i,n)};di.prototype.pointFromX=function(e,t){e=new Ci(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=this.c2.redSub(this.a.redMul(i)),s=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=n.redMul(s.redInvm()),a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");var f=a.fromRed().isOdd();return(t&&!f||!t&&f)&&(a=a.redNeg()),this.point(e,a)};di.prototype.pointFromY=function(e,t){e=new Ci(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr(),n=i.redSub(this.c2),s=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=n.redMul(s.redInvm());if(o.cmp(this.zero)===0){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(a.redSqr().redSub(o).cmp(this.zero)!==0)throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)};di.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),n=t.redMul(this.a).redAdd(i),s=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return n.cmp(s)===0};function Ye(r,e,t,i,n){Tf.BasePoint.call(this,r,"projective"),e===null&&t===null&&i===null?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new Ci(e,16),this.y=new Ci(t,16),this.z=i?new Ci(i,16):this.curve.one,this.t=n&&new Ci(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.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}Jb(Ye,Tf.BasePoint);di.prototype.pointFromJSON=function(e){return Ye.fromJSON(this,e)};di.prototype.point=function(e,t,i,n){return new Ye(this,e,t,i,n)};Ye.fromJSON=function(e,t){return new Ye(e,t[0],t[1],t[2])};Ye.prototype.inspect=function(){return this.isInfinity()?"":""};Ye.prototype.isInfinity=function(){return this.x.cmpn(0)===0&&(this.y.cmp(this.z)===0||this.zOne&&this.y.cmp(this.curve.c)===0)};Ye.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var n=this.curve._mulA(e),s=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(i),f=n.redSub(t),u=s.redMul(a),g=o.redMul(f),y=s.redMul(f),S=a.redMul(o);return this.curve.point(u,g,S,y)};Ye.prototype._projDbl=function(){var e=this.x.redAdd(this.y).redSqr(),t=this.x.redSqr(),i=this.y.redSqr(),n,s,o,a,f,u;if(this.curve.twisted){a=this.curve._mulA(t);var g=a.redAdd(i);this.zOne?(n=e.redSub(t).redSub(i).redMul(g.redSub(this.curve.two)),s=g.redMul(a.redSub(i)),o=g.redSqr().redSub(g).redSub(g)):(f=this.z.redSqr(),u=g.redSub(f).redISub(f),n=e.redSub(t).redISub(i).redMul(u),s=g.redMul(a.redSub(i)),o=g.redMul(u))}else a=t.redAdd(i),f=this.curve._mulC(this.z).redSqr(),u=a.redSub(f).redSub(f),n=this.curve._mulC(e.redISub(a)).redMul(u),s=this.curve._mulC(a).redMul(t.redISub(i)),o=a.redMul(u);return this.curve.point(n,s,o)};Ye.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()};Ye.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),s=this.z.redMul(e.z.redAdd(e.z)),o=i.redSub(t),a=s.redSub(n),f=s.redAdd(n),u=i.redAdd(t),g=o.redMul(a),y=f.redMul(u),S=o.redMul(u),I=a.redMul(f);return this.curve.point(g,y,I,S)};Ye.prototype._projAdd=function(e){var t=this.z.redMul(e.z),i=t.redSqr(),n=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(n).redMul(s),a=i.redSub(o),f=i.redAdd(o),u=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(s),g=t.redMul(a).redMul(u),y,S;return this.curve.twisted?(y=t.redMul(f).redMul(s.redSub(this.curve._mulA(n))),S=a.redMul(f)):(y=t.redMul(f).redMul(s.redSub(n)),S=this.curve._mulC(a).redMul(f)),this.curve.point(g,y,S)};Ye.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)};Ye.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)};Ye.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)};Ye.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)};Ye.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this};Ye.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())};Ye.prototype.getX=function(){return this.normalize(),this.x.fromRed()};Ye.prototype.getY=function(){return this.normalize(),this.y.fromRed()};Ye.prototype.eq=function(e){return this===e||this.getX().cmp(e.getX())===0&&this.getY().cmp(e.getY())===0};Ye.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(this.x.cmp(t)===0)return!0;for(var i=e.clone(),n=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),this.x.cmp(t)===0)return!0}};Ye.prototype.toP=Ye.prototype.normalize;Ye.prototype.mixedAdd=Ye.prototype.add});var Gd=J(Qb=>{"use strict";var Pf=Qb;Pf.base=pa();Pf.short=$b();Pf.mont=Wb();Pf.edwards=Xb()});var ev=J((AC,Zb)=>{Zb.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}});var Rf=J(iv=>{"use strict";var Jd=iv,tn=ca(),Wd=Gd(),qE=Yt(),tv=qE.assert;function rv(r){r.type==="short"?this.curve=new Wd.short(r):r.type==="edwards"?this.curve=new Wd.edwards(r):this.curve=new Wd.mont(r),this.g=this.curve.g,this.n=this.curve.n,this.hash=r.hash,tv(this.g.validate(),"Invalid curve"),tv(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}Jd.PresetCurve=rv;function rn(r,e){Object.defineProperty(Jd,r,{configurable:!0,enumerable:!0,get:function(){var t=new rv(e);return Object.defineProperty(Jd,r,{configurable:!0,enumerable:!0,value:t}),t}})}rn("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:tn.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]});rn("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:tn.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]});rn("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:tn.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]});rn("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:tn.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"]});rn("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:tn.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"]});rn("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:tn.sha256,gRed:!1,g:["9"]});rn("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:tn.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});var Yd;try{Yd=ev()}catch{Yd=void 0}rn("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:tn.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",Yd]})});var ov=J((TC,sv)=>{"use strict";var BE=ca(),Jn=zd(),nv=Wi();function nn(r){if(!(this instanceof nn))return new nn(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Jn.toArray(r.entropy,r.entropyEnc||"hex"),t=Jn.toArray(r.nonce,r.nonceEnc||"hex"),i=Jn.toArray(r.pers,r.persEnc||"hex");nv(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}sv.exports=nn;nn.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);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(i||[])),this._reseed=1};nn.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Jn.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length{"use strict";var kE=hi(),zE=Yt(),Xd=zE.assert;function Dt(r,e){this.ec=r,this.priv=null,this.pub=null,e.priv&&this._importPrivate(e.priv,e.privEnc),e.pub&&this._importPublic(e.pub,e.pubEnc)}av.exports=Dt;Dt.fromPublic=function(e,t,i){return t instanceof Dt?t:new Dt(e,{pub:t,pubEnc:i})};Dt.fromPrivate=function(e,t,i){return t instanceof Dt?t:new Dt(e,{priv:t,privEnc:i})};Dt.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}};Dt.prototype.getPublic=function(e,t){return typeof e=="string"&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub};Dt.prototype.getPrivate=function(e){return e==="hex"?this.priv.toString(16,2):this.priv};Dt.prototype._importPrivate=function(e,t){this.priv=new kE(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)};Dt.prototype._importPublic=function(e,t){if(e.x||e.y){this.ec.curve.type==="mont"?Xd(e.x,"Need x coordinate"):(this.ec.curve.type==="short"||this.ec.curve.type==="edwards")&&Xd(e.x&&e.y,"Need both x and y coordinate"),this.pub=this.ec.curve.point(e.x,e.y);return}this.pub=this.ec.curve.decodePoint(e,t)};Dt.prototype.derive=function(e){return e.validate()||Xd(e.validate(),"public point not validated"),e.mul(this.priv).getX()};Dt.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)};Dt.prototype.verify=function(e,t){return this.ec.verify(e,t,this)};Dt.prototype.inspect=function(){return""}});var hv=J((RC,uv)=>{"use strict";var Nf=hi(),el=Yt(),jE=el.assert;function Df(r,e){if(r instanceof Df)return r;this._importDER(r,e)||(jE(r.r&&r.s,"Signature without r or s"),this.r=new Nf(r.r,16),this.s=new Nf(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}uv.exports=Df;function KE(){this.place=0}function Qd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4||r[e.place]===0)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function fv(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}Df.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=fv(t),i=fv(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Zd(n,t.length),n=n.concat(t),n.push(2),Zd(n,i.length);var s=n.concat(i),o=[48];return Zd(o,s.length),o=o.concat(s),el.encode(o,e)}});var gv=J((NC,pv)=>{"use strict";var Yn=hi(),dv=ov(),VE=Yt(),tl=Rf(),$E=$d(),lv=VE.assert,rl=cv(),Cf=hv();function pr(r){if(!(this instanceof pr))return new pr(r);typeof r=="string"&&(lv(Object.prototype.hasOwnProperty.call(tl,r),"Unknown curve "+r),r=tl[r]),r instanceof tl.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}pv.exports=pr;pr.prototype.keyPair=function(e){return new rl(this,e)};pr.prototype.keyFromPrivate=function(e,t){return rl.fromPrivate(this,e,t)};pr.prototype.keyFromPublic=function(e,t){return rl.fromPublic(this,e,t)};pr.prototype.genKeyPair=function(e){e||(e={});for(var t=new dv({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||$E(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Yn(2));;){var s=new Yn(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};pr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};pr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Yn(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new dv({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Yn(1)),g=0;;g++){var y=n.k?n.k(g):new Yn(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var P=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),O^=1),new Cf({r:A,s:P,recoveryParam:O})}}}}}};pr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Yn(e,16)),i=this.keyFromPublic(i,n),t=new Cf(t,"hex");var s=t.r,o=t.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),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};pr.prototype.recoverPubKey=function(r,e,t,i){lv((3&t)===t,"The recovery param is more than two bits"),e=new Cf(e,i);var n=this.n,s=new Yn(r),o=e.r,a=e.s,f=t&1,u=t>>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),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};pr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new Cf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")}});var yv=J((DC,vv)=>{"use strict";var ga=Yt(),bv=ga.assert,mv=ga.parseBytes,Ys=ga.cachedProperty;function bt(r,e){this.eddsa=r,this._secret=mv(e.secret),r.isPoint(e.pub)?this._pub=e.pub:this._pubBytes=mv(e.pub)}bt.fromPublic=function(e,t){return t instanceof bt?t:new bt(e,{pub:t})};bt.fromSecret=function(e,t){return t instanceof bt?t:new bt(e,{secret:t})};bt.prototype.secret=function(){return this._secret};Ys(bt,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())});Ys(bt,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())});Ys(bt,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[i]&=127,n[i]|=64,n});Ys(bt,"priv",function(){return this.eddsa.decodeInt(this.privBytes())});Ys(bt,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()});Ys(bt,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)});bt.prototype.sign=function(e){return bv(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)};bt.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)};bt.prototype.getSecret=function(e){return bv(this._secret,"KeyPair is public only"),ga.encode(this.secret(),e)};bt.prototype.getPublic=function(e){return ga.encode(this.pubBytes(),e)};vv.exports=bt});var _v=J((CC,xv)=>{"use strict";var HE=hi(),Of=Yt(),wv=Of.assert,Lf=Of.cachedProperty,GE=Of.parseBytes;function Xn(r,e){this.eddsa=r,typeof e!="object"&&(e=GE(e)),Array.isArray(e)&&(wv(e.length===r.encodingLength*2,"Signature has invalid size"),e={R:e.slice(0,r.encodingLength),S:e.slice(r.encodingLength)}),wv(e.R&&e.S,"Signature without R or S"),r.isPoint(e.R)&&(this._R=e.R),e.S instanceof HE&&(this._S=e.S),this._Rencoded=Array.isArray(e.R)?e.R:e.Rencoded,this._Sencoded=Array.isArray(e.S)?e.S:e.Sencoded}Lf(Xn,"S",function(){return this.eddsa.decodeInt(this.Sencoded())});Lf(Xn,"R",function(){return this.eddsa.decodePoint(this.Rencoded())});Lf(Xn,"Rencoded",function(){return this.eddsa.encodePoint(this.R())});Lf(Xn,"Sencoded",function(){return this.eddsa.encodeInt(this.S())});Xn.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())};Xn.prototype.toHex=function(){return Of.encode(this.toBytes(),"hex").toUpperCase()};xv.exports=Xn});var Mv=J((OC,Av)=>{"use strict";var WE=ca(),JE=Rf(),Xs=Yt(),YE=Xs.assert,Sv=Xs.parseBytes,Iv=yv(),Ev=_v();function Kt(r){if(YE(r==="ed25519","only tested with ed25519 so far"),!(this instanceof Kt))return new Kt(r);r=JE[r].curve,this.curve=r,this.g=r.g,this.g.precompute(r.n.bitLength()+1),this.pointClass=r.point().constructor,this.encodingLength=Math.ceil(r.n.bitLength()/8),this.hash=WE.sha512}Av.exports=Kt;Kt.prototype.sign=function(e,t){e=Sv(e);var i=this.keyFromSecret(t),n=this.hashInt(i.messagePrefix(),e),s=this.g.mul(n),o=this.encodePoint(s),a=this.hashInt(o,i.pubBytes(),e).mul(i.priv()),f=n.add(a).umod(this.curve.n);return this.makeSignature({R:s,S:f,Rencoded:o})};Kt.prototype.verify=function(e,t,i){if(e=Sv(e),t=this.makeSignature(t),t.S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var n=this.keyFromPublic(i),s=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S()),a=t.R().add(n.pub().mul(s));return a.eq(o)};Kt.prototype.hashInt=function(){for(var e=this.hash(),t=0;t{"use strict";var Qn=Tv;Qn.version=Ub().version;Qn.utils=Yt();Qn.rand=$d();Qn.curve=Gd();Qn.curves=Rf();Qn.ec=gv();Qn.eddsa=Mv()});var qy=J(fn=>{"use strict";Object.defineProperty(fn,"__esModule",{value:!0});fn.isBrowserCryptoAvailable=fn.getSubtleCrypto=fn.getBrowerCrypto=void 0;function Pl(){return(global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}fn.getBrowerCrypto=Pl;function Uy(){let r=Pl();return r.subtle||r.webkitSubtle}fn.getSubtleCrypto=Uy;function d7(){return!!Pl()&&!!Uy()}fn.isBrowserCryptoAvailable=d7});var zy=J(un=>{"use strict";Object.defineProperty(un,"__esModule",{value:!0});un.isBrowser=un.isNode=un.isReactNative=void 0;function By(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}un.isReactNative=By;function ky(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}un.isNode=ky;function l7(){return!By()&&!ky()}un.isBrowser=l7});var Rl=J(Wf=>{"use strict";Object.defineProperty(Wf,"__esModule",{value:!0});var jy=(vs(),Ao(bs));jy.__exportStar(qy(),Wf);jy.__exportStar(zy(),Wf)});var Jy=J((mO,Wy)=>{"use strict";Wy.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}});var Cw=J((Da,ho)=>{var I7=200,Vl="__lodash_hash_undefined__",cu=1,uw=2,hw=9007199254740991,tu="[object Arguments]",Ul="[object Array]",A7="[object AsyncFunction]",dw="[object Boolean]",lw="[object Date]",pw="[object Error]",gw="[object Function]",M7="[object GeneratorFunction]",ru="[object Map]",mw="[object Number]",T7="[object Null]",uo="[object Object]",Zy="[object Promise]",P7="[object Proxy]",bw="[object RegExp]",iu="[object Set]",vw="[object String]",R7="[object Symbol]",N7="[object Undefined]",ql="[object WeakMap]",yw="[object ArrayBuffer]",nu="[object DataView]",D7="[object Float32Array]",C7="[object Float64Array]",O7="[object Int8Array]",L7="[object Int16Array]",F7="[object Int32Array]",U7="[object Uint8Array]",q7="[object Uint8ClampedArray]",B7="[object Uint16Array]",k7="[object Uint32Array]",z7=/[\\^$.*+?()[\]{}|]/g,j7=/^\[object .+?Constructor\]$/,K7=/^(?:0|[1-9]\d*)$/,Ze={};Ze[D7]=Ze[C7]=Ze[O7]=Ze[L7]=Ze[F7]=Ze[U7]=Ze[q7]=Ze[B7]=Ze[k7]=!0;Ze[tu]=Ze[Ul]=Ze[yw]=Ze[dw]=Ze[nu]=Ze[lw]=Ze[pw]=Ze[gw]=Ze[ru]=Ze[mw]=Ze[uo]=Ze[bw]=Ze[iu]=Ze[vw]=Ze[ql]=!1;var ww=typeof global=="object"&&global&&global.Object===Object&&global,V7=typeof self=="object"&&self&&self.Object===Object&&self,Ui=ww||V7||Function("return this")(),xw=typeof Da=="object"&&Da&&!Da.nodeType&&Da,ew=xw&&typeof ho=="object"&&ho&&!ho.nodeType&&ho,_w=ew&&ew.exports===xw,Ol=_w&&ww.process,tw=function(){try{return Ol&&Ol.binding&&Ol.binding("util")}catch{}}(),rw=tw&&tw.isTypedArray;function $7(r,e){for(var t=-1,i=r==null?0:r.length,n=0,s=[];++t-1}function xS(r,e){var t=this.__data__,i=uu(t,r);return i<0?(++this.size,t.push([r,e])):t[i][1]=e,this}qi.prototype.clear=bS;qi.prototype.delete=vS;qi.prototype.get=yS;qi.prototype.has=wS;qi.prototype.set=xS;function os(r){var e=-1,t=r==null?0:r.length;for(this.clear();++ea))return!1;var u=s.get(r);if(u&&s.get(e))return u==e;var g=-1,y=!0,S=t&uw?new ou:void 0;for(s.set(r,e),s.set(e,r);++g-1&&r%1==0&&r-1&&r%1==0&&r<=hw}function Nw(r){var e=typeof r;return r!=null&&(e=="object"||e=="function")}function La(r){return r!=null&&typeof r=="object"}var Dw=rw?J7(rw):qS;function QS(r){return YS(r)?OS(r):BS(r)}function ZS(){return[]}function eI(){return!1}ho.exports=XS});var N2=J((QL,R2)=>{R2.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var vn=J(fs=>{var U0,LM=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];fs.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17};fs.getSymbolTotalCodewords=function(e){return LM[e]};fs.getBCHDigit=function(r){let e=0;for(;r!==0;)e++,r>>>=1;return e};fs.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');U0=e};fs.isKanjiModeEnabled=function(){return typeof U0<"u"};fs.toSJIS=function(e){return U0(e)}});var _u=J(br=>{br.L={bit:1};br.M={bit:0};br.Q={bit:3};br.H={bit:2};function FM(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return br.L;case"m":case"medium":return br.M;case"q":case"quartile":return br.Q;case"h":case"high":return br.H;default:throw new Error("Unknown EC Level: "+r)}}br.isValid=function(e){return e&&typeof e.bit<"u"&&e.bit>=0&&e.bit<4};br.from=function(e,t){if(br.isValid(e))return e;try{return FM(e)}catch{return t}}});var O2=J((tF,C2)=>{function D2(){this.buffer=[],this.length=0}D2.prototype={get:function(r){let e=Math.floor(r/8);return(this.buffer[e]>>>7-r%8&1)===1},put:function(r,e){for(let t=0;t>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),r&&(this.buffer[e]|=128>>>this.length%8),this.length++}};C2.exports=D2});var F2=J((rF,L2)=>{function za(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}za.prototype.set=function(r,e,t,i){let n=r*this.size+e;this.data[n]=t,i&&(this.reservedBit[n]=!0)};za.prototype.get=function(r,e){return this.data[r*this.size+e]};za.prototype.xor=function(r,e,t){this.data[r*this.size+e]^=t};za.prototype.isReserved=function(r,e){return this.reservedBit[r*this.size+e]};L2.exports=za});var U2=J(Eu=>{var UM=vn().getSymbolSize;Eu.getRowColCoords=function(e){if(e===1)return[];let t=Math.floor(e/7)+2,i=UM(e),n=i===145?26:Math.ceil((i-13)/(2*t-2))*2,s=[i-7];for(let o=1;o{var qM=vn().getSymbolSize,q2=7;B2.getPositions=function(e){let t=qM(e);return[[0,0],[t-q2,0],[0,t-q2]]}});var z2=J(Xe=>{Xe.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var us={N1:3,N2:3,N3:40,N4:10};Xe.isValid=function(e){return e!=null&&e!==""&&!isNaN(e)&&e>=0&&e<=7};Xe.from=function(e){return Xe.isValid(e)?parseInt(e,10):void 0};Xe.getPenaltyN1=function(e){let t=e.size,i=0,n=0,s=0,o=null,a=null;for(let f=0;f=5&&(i+=us.N1+(n-5)),o=g,n=1),g=e.get(u,f),g===a?s++:(s>=5&&(i+=us.N1+(s-5)),a=g,s=1)}n>=5&&(i+=us.N1+(n-5)),s>=5&&(i+=us.N1+(s-5))}return i};Xe.getPenaltyN2=function(e){let t=e.size,i=0;for(let n=0;n=10&&(n===1488||n===93)&&i++,s=s<<1&2047|e.get(a,o),a>=10&&(s===1488||s===93)&&i++}return i*us.N3};Xe.getPenaltyN4=function(e){let t=0,i=e.data.length;for(let s=0;s{var yn=_u(),Su=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Iu=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];q0.getBlocksCount=function(e,t){switch(t){case yn.L:return Su[(e-1)*4+0];case yn.M:return Su[(e-1)*4+1];case yn.Q:return Su[(e-1)*4+2];case yn.H:return Su[(e-1)*4+3];default:return}};q0.getTotalCodewordsCount=function(e,t){switch(t){case yn.L:return Iu[(e-1)*4+0];case yn.M:return Iu[(e-1)*4+1];case yn.Q:return Iu[(e-1)*4+2];case yn.H:return Iu[(e-1)*4+3];default:return}}});var j2=J(Mu=>{var ja=new Uint8Array(512),Au=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)ja[t]=e,Au[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)ja[t]=ja[t-255]})();Mu.log=function(e){if(e<1)throw new Error("log("+e+")");return Au[e]};Mu.exp=function(e){return ja[e]};Mu.mul=function(e,t){return e===0||t===0?0:ja[Au[e]+Au[t]]}});var K2=J(Ka=>{var k0=j2();Ka.mul=function(e,t){let i=new Uint8Array(e.length+t.length-1);for(let n=0;n=0;){let n=i[0];for(let o=0;o{var V2=K2();function z0(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}z0.prototype.initialize=function(e){this.degree=e,this.genPoly=V2.generateECPolynomial(this.degree)};z0.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");let t=new Uint8Array(e.length+this.degree);t.set(e);let i=V2.mod(t,this.genPoly),n=this.degree-i.length;if(n>0){let s=new Uint8Array(this.degree);return s.set(i,n),s}return i};$2.exports=z0});var j0=J(G2=>{G2.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}});var K0=J(zi=>{var W2="[0-9]+",kM="[A-Z $%*+\\-./:]+",Va="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Va=Va.replace(/u/g,"\\u");var zM="(?:(?![A-Z0-9 $%*+\\-./:]|"+Va+`)(?:.|[\r -]))+`;zi.KANJI=new RegExp(Va,"g");zi.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");zi.BYTE=new RegExp(zM,"g");zi.NUMERIC=new RegExp(W2,"g");zi.ALPHANUMERIC=new RegExp(kM,"g");var jM=new RegExp("^"+Va+"$"),KM=new RegExp("^"+W2+"$"),VM=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");zi.testKanji=function(e){return jM.test(e)};zi.testNumeric=function(e){return KM.test(e)};zi.testAlphanumeric=function(e){return VM.test(e)}});var wn=J(ht=>{var $M=j0(),V0=K0();ht.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};ht.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};ht.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};ht.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};ht.MIXED={bit:-1};ht.getCharCountIndicator=function(e,t){if(!e.ccBits)throw new Error("Invalid mode: "+e);if(!$M.isValid(t))throw new Error("Invalid version: "+t);return t>=1&&t<10?e.ccBits[0]:t<27?e.ccBits[1]:e.ccBits[2]};ht.getBestModeForData=function(e){return V0.testNumeric(e)?ht.NUMERIC:V0.testAlphanumeric(e)?ht.ALPHANUMERIC:V0.testKanji(e)?ht.KANJI:ht.BYTE};ht.toString=function(e){if(e&&e.id)return e.id;throw new Error("Invalid mode")};ht.isValid=function(e){return e&&e.bit&&e.ccBits};function HM(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return ht.NUMERIC;case"alphanumeric":return ht.ALPHANUMERIC;case"kanji":return ht.KANJI;case"byte":return ht.BYTE;default:throw new Error("Unknown mode: "+r)}}ht.from=function(e,t){if(ht.isValid(e))return e;try{return HM(e)}catch{return t}}});var Z2=J(hs=>{var Tu=vn(),GM=B0(),J2=_u(),xn=wn(),$0=j0(),X2=7973,Y2=Tu.getBCHDigit(X2);function WM(r,e,t){for(let i=1;i<=40;i++)if(e<=hs.getCapacity(i,t,r))return i}function Q2(r,e){return xn.getCharCountIndicator(r,e)+4}function JM(r,e){let t=0;return r.forEach(function(i){let n=Q2(i.mode,e);t+=n+i.getBitsLength()}),t}function YM(r,e){for(let t=1;t<=40;t++)if(JM(r,t)<=hs.getCapacity(t,e,xn.MIXED))return t}hs.from=function(e,t){return $0.isValid(e)?parseInt(e,10):t};hs.getCapacity=function(e,t,i){if(!$0.isValid(e))throw new Error("Invalid QR Code version");typeof i>"u"&&(i=xn.BYTE);let n=Tu.getSymbolTotalCodewords(e),s=GM.getTotalCodewordsCount(e,t),o=(n-s)*8;if(i===xn.MIXED)return o;let a=o-Q2(i,e);switch(i){case xn.NUMERIC:return Math.floor(a/10*3);case xn.ALPHANUMERIC:return Math.floor(a/11*2);case xn.KANJI:return Math.floor(a/13);case xn.BYTE:default:return Math.floor(a/8)}};hs.getBestVersionForData=function(e,t){let i,n=J2.from(t,J2.M);if(Array.isArray(e)){if(e.length>1)return YM(e,n);if(e.length===0)return 1;i=e[0]}else i=e;return WM(i.mode,i.getLength(),n)};hs.getEncodedBits=function(e){if(!$0.isValid(e)||e<7)throw new Error("Invalid QR Code version");let t=e<<12;for(;Tu.getBCHDigit(t)-Y2>=0;)t^=X2<{var H0=vn(),t3=1335,XM=21522,e3=H0.getBCHDigit(t3);r3.getEncodedBits=function(e,t){let i=e.bit<<3|t,n=i<<10;for(;H0.getBCHDigit(n)-e3>=0;)n^=t3<{var QM=wn();function wo(r){this.mode=QM.NUMERIC,this.data=r.toString()}wo.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)};wo.prototype.getLength=function(){return this.data.length};wo.prototype.getBitsLength=function(){return wo.getBitsLength(this.data.length)};wo.prototype.write=function(e){let t,i,n;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),n=parseInt(i,10),e.put(n,10);let s=this.data.length-t;s>0&&(i=this.data.substr(t),n=parseInt(i,10),e.put(n,s*3+1))};n3.exports=wo});var a3=J((mF,o3)=>{var ZM=wn(),G0=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function xo(r){this.mode=ZM.ALPHANUMERIC,this.data=r}xo.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)};xo.prototype.getLength=function(){return this.data.length};xo.prototype.getBitsLength=function(){return xo.getBitsLength(this.data.length)};xo.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=G0.indexOf(this.data[t])*45;i+=G0.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(G0.indexOf(this.data[t]),6)};o3.exports=xo});var f3=J((bF,c3)=>{var eT=wn();function _o(r){this.mode=eT.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}_o.getBitsLength=function(e){return e*8};_o.prototype.getLength=function(){return this.data.length};_o.prototype.getBitsLength=function(){return _o.getBitsLength(this.data.length)};_o.prototype.write=function(r){for(let e=0,t=this.data.length;e{var tT=wn(),rT=vn();function Eo(r){this.mode=tT.KANJI,this.data=r}Eo.getBitsLength=function(e){return e*13};Eo.prototype.getLength=function(){return this.data.length};Eo.prototype.getBitsLength=function(){return Eo.getBitsLength(this.data.length)};Eo.prototype.write=function(r){let e;for(e=0;e=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` -Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),r.put(t,13)}};u3.exports=Eo});var d3=J((yF,W0)=>{"use strict";var $a={single_source_shortest_paths:function(r,e,t){var i={},n={};n[e]=0;var s=$a.PriorityQueue.make();s.push(e,0);for(var o,a,f,u,g,y,S,I,A;!s.empty();){o=s.pop(),a=o.value,u=o.cost,g=r[a]||{};for(f in g)g.hasOwnProperty(f)&&(y=g[f],S=u+y,I=n[f],A=typeof n[f]>"u",(A||I>S)&&(n[f]=S,s.push(f,S),i[f]=a))}if(typeof t<"u"&&typeof n[t]>"u"){var P=["Could not find a path from ",e," to ",t,"."].join("");throw new Error(P)}return i},extract_shortest_path_from_predecessor_list:function(r,e){for(var t=[],i=e,n;i;)t.push(i),n=r[i],i=r[i];return t.reverse(),t},find_path:function(r,e,t){var i=$a.single_source_shortest_paths(r,e,t);return $a.extract_shortest_path_from_predecessor_list(i,t)},PriorityQueue:{make:function(r){var e=$a.PriorityQueue,t={},i;r=r||{};for(i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);return t.queue=[],t.sorter=r.sorter||e.default_sorter,t},default_sorter:function(r,e){return r.cost-e.cost},push:function(r,e){var t={value:r,cost:e};this.queue.push(t),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof W0<"u"&&(W0.exports=$a)});var w3=J(So=>{var je=wn(),g3=s3(),m3=a3(),b3=f3(),v3=h3(),Ha=K0(),Pu=vn(),iT=d3();function l3(r){return unescape(encodeURIComponent(r)).length}function Ga(r,e,t){let i=[],n;for(;(n=r.exec(t))!==null;)i.push({data:n[0],index:n.index,mode:e,length:n[0].length});return i}function y3(r){let e=Ga(Ha.NUMERIC,je.NUMERIC,r),t=Ga(Ha.ALPHANUMERIC,je.ALPHANUMERIC,r),i,n;return Pu.isKanjiModeEnabled()?(i=Ga(Ha.BYTE,je.BYTE,r),n=Ga(Ha.KANJI,je.KANJI,r)):(i=Ga(Ha.BYTE_KANJI,je.BYTE,r),n=[]),e.concat(t,i,n).sort(function(o,a){return o.index-a.index}).map(function(o){return{data:o.data,mode:o.mode,length:o.length}})}function J0(r,e){switch(e){case je.NUMERIC:return g3.getBitsLength(r);case je.ALPHANUMERIC:return m3.getBitsLength(r);case je.KANJI:return v3.getBitsLength(r);case je.BYTE:return b3.getBitsLength(r)}}function nT(r){return r.reduce(function(e,t){let i=e.length-1>=0?e[e.length-1]:null;return i&&i.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function sT(r){let e=[];for(let t=0;t{var Nu=vn(),Y0=_u(),aT=O2(),cT=F2(),fT=U2(),uT=k2(),Z0=z2(),ep=B0(),hT=H2(),Ru=Z2(),dT=i3(),lT=wn(),X0=w3();function pT(r,e){let t=r.size,i=uT.getPositions(e);for(let n=0;n=0&&a<=6&&(f===0||f===6)||f>=0&&f<=6&&(a===0||a===6)||a>=2&&a<=4&&f>=2&&f<=4?r.set(s+a,o+f,!0,!0):r.set(s+a,o+f,!1,!0))}}function gT(r){let e=r.size;for(let t=8;t>a&1)===1,r.set(n,s,o,!0),r.set(s,n,o,!0)}function Q0(r,e,t){let i=r.size,n=dT.getEncodedBits(e,t),s,o;for(s=0;s<15;s++)o=(n>>s&1)===1,s<6?r.set(s,8,o,!0):s<8?r.set(s+1,8,o,!0):r.set(i-15+s,8,o,!0),s<8?r.set(8,i-s-1,o,!0):s<9?r.set(8,15-s-1+1,o,!0):r.set(8,15-s-1,o,!0);r.set(i-8,8,1,!0)}function vT(r,e){let t=r.size,i=-1,n=t-1,s=7,o=0;for(let a=t-1;a>0;a-=2)for(a===6&&a--;;){for(let f=0;f<2;f++)if(!r.isReserved(n,a-f)){let u=!1;o>>s&1)===1),r.set(n,a-f,u),s--,s===-1&&(o++,s=7)}if(n+=i,n<0||t<=n){n-=i,i=-i;break}}}function yT(r,e,t){let i=new aT;t.forEach(function(f){i.put(f.mode.bit,4),i.put(f.getLength(),lT.getCharCountIndicator(f.mode,r)),f.write(i)});let n=Nu.getSymbolTotalCodewords(r),s=ep.getTotalCodewordsCount(r,e),o=(n-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);let a=(o-i.getLengthInBits())/8;for(let f=0;f=7&&bT(f,e),vT(f,o),isNaN(i)&&(i=Z0.getBestMask(f,Q0.bind(null,f,t))),Z0.applyMask(i,f),Q0(f,t,i),{modules:f,version:e,errorCorrectionLevel:t,maskPattern:i,segments:n}}x3.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=Y0.M,n,s;return typeof t<"u"&&(i=Y0.from(t.errorCorrectionLevel,Y0.M),n=Ru.from(t.version),s=Z0.from(t.maskPattern),t.toSJISFunc&&Nu.setToSJISFunction(t.toSJISFunc)),xT(e,n,i,s)}});var tp=J(ds=>{function E3(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let e=r.slice().replace("#","").split("");if(e.length<3||e.length===5||e.length>8)throw new Error("Invalid hex color: "+r);(e.length===3||e.length===4)&&(e=Array.prototype.concat.apply([],e.map(function(i){return[i,i]}))),e.length===6&&e.push("F","F");let t=parseInt(e.join(""),16);return{r:t>>24&255,g:t>>16&255,b:t>>8&255,a:t&255,hex:"#"+e.slice(0,6).join("")}}ds.getOptions=function(e){e||(e={}),e.color||(e.color={});let t=typeof e.margin>"u"||e.margin===null||e.margin<0?4:e.margin,i=e.width&&e.width>=21?e.width:void 0,n=e.scale||4;return{width:i,scale:i?4:n,margin:t,color:{dark:E3(e.color.dark||"#000000ff"),light:E3(e.color.light||"#ffffffff")},type:e.type,rendererOpts:e.rendererOpts||{}}};ds.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale};ds.getImageWidth=function(e,t){let i=ds.getScale(e,t);return Math.floor((e+t.margin*2)*i)};ds.qrToImageData=function(e,t,i){let n=t.modules.size,s=t.modules.data,o=ds.getScale(n,i),a=Math.floor((n+i.margin*2)*o),f=i.margin*o,u=[i.color.light,i.color.dark];for(let g=0;g=f&&y>=f&&g{var rp=tp();function _T(r,e,t){r.clearRect(0,0,e.width,e.height),e.style||(e.style={}),e.height=t,e.width=t,e.style.height=t+"px",e.style.width=t+"px"}function ET(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}Du.render=function(e,t,i){let n=i,s=t;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),t||(s=ET()),n=rp.getOptions(n);let o=rp.getImageWidth(e.modules.size,n),a=s.getContext("2d"),f=a.createImageData(o,o);return rp.qrToImageData(f.data,e,n),_T(a,s,o),a.putImageData(f,0,0),s};Du.renderToDataURL=function(e,t,i){let n=i;typeof n>"u"&&(!t||!t.getContext)&&(n=t,t=void 0),n||(n={});let s=Du.render(e,t,n),o=n.type||"image/png",a=n.rendererOpts||{};return s.toDataURL(o,a.quality)}});var M3=J(A3=>{var ST=tp();function I3(r,e){let t=r.a/255,i=e+'="'+r.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function ip(r,e,t){let i=r+e;return typeof t<"u"&&(i+=" "+t),i}function IT(r,e,t){let i="",n=0,s=!1,o=0;for(let a=0;a0&&f>0&&r[a-1]||(i+=s?ip("M",f+t,.5+u+t):ip("m",n,0),n=0,s=!1),f+1':"",u="',g='viewBox="0 0 '+a+" "+a+'"',S=''+f+u+` -`;return typeof i=="function"&&i(null,S),S}});var P3=J(Wa=>{var AT=N2(),np=_3(),T3=S3(),MT=M3();function sp(r,e,t,i,n){let s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!AT())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(n=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof n>"u"?(n=i,i=void 0):(n=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(f,u){try{let g=np.create(t,i);f(r(g,e,i))}catch(g){u(g)}})}try{let f=np.create(t,i);n(null,r(f,e,i))}catch(f){n(f)}}Wa.create=np.create;Wa.toCanvas=sp.bind(null,T3.render);Wa.toDataURL=sp.bind(null,T3.renderToDataURL);Wa.toString=sp.bind(null,function(r,e,t){return MT.render(r,t)})});var ls="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",up=new Uint8Array(256);for(let r=0;r/^[0-9a-fA-F]{64}$/.test(r),Cn=r=>J3.encode(r),ji=r=>Y3.decode(r),or=r=>{if(!/^[0-9a-fA-F]+$/.test(r)||r.length%2!==0)throw new Error("Invalid hex string");let e=new Uint8Array(r.length/2);for(let t=0;tArray.from(r).map(e=>e.toString(16).padStart(2,"0")).join(""),Xa=r=>yr(Cn(r)),On=r=>{r=r.replace(/[^A-Za-z0-9+/=]/g,"");let e=0;r.endsWith("==")?e=2:r.endsWith("=")&&(e=1);let t=Math.floor(r.length*6/8-e),i=new Uint8Array(t),n=0,s=0,o=0;for(let a=0;a=8&&(s-=8,i[o++]=n>>s&255)}return i},X3=r=>{let e="",t=r.length;for(let i=0;i>18&63,u=a>>12&63,g=a>>6&63,y=a&63;e+=ls.charAt(f),e+=ls.charAt(u),e+=i+1ji(On(r)),Ki=r=>{let e=typeof r=="string"?Cn(r):r;return X3(e)};function Q3(r){let e=[],t=/([^[\]]+)|\[(.*?)\]/g,i;for(;(i=t.exec(r))!==null;)i[1]!==void 0?e.push(i[1]):i[2]!==void 0&&(i[2]===""?e.push(""):/^\d+$/.test(i[2])?e.push(Number(i[2])):e.push(i[2]));return e}function Z3(r,e,t){let i=r;for(let n=0;n{zu([...r,""],i,t)});else for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&zu([...r,i],e[i],t);else{let i=r.map((n,s)=>s===0?encodeURIComponent(String(n)):n===""?"[]":`[${encodeURIComponent(String(n))}]`).join("");t.push(`${i}=${encodeURIComponent(e)}`)}}function ju(r){let e=new URLSearchParams(r),t={};for(let[i,n]of e.entries()){let s=Q3(i);Z3(t,s,n)}return t}function dp(r){let e=[];return zu([],r,e),e.join("&")}var e6=()=>typeof window<"u"&&typeof window.location<"u",To=()=>{if(e6()){let r=window.location.ancestorOrigins;return r?.[r.length-1]??"*"}return"*"},Ku=()=>{let r=window;return!!(r?.ReactNativeWebView||r?.webkit)};var _i=class{constructor(e){this.address=new Uint8Array([]);this.nonce=0;this.balance="0";hp(e)&&(this.address=or(e))}update(e){this.nonce=e.nonce,this.balance=e.balance}incrementNonce(){this.nonce=this.nonce+1}getNonceThenIncrement(){let e=this.nonce;return this.nonce=this.nonce+1,e}toJSON(){return{address:yr(this.address),nonce:this.nonce,balance:this.balance}}bech32(){return yr(this.address)}};var lp=1e9,pp=0,Qa=2,gp=2,Vu=64,mp=1;var bp="sdk-js";var vp="hook/login",yp="hook/logout";var wp="hook/sign",xp="hook/2fa",_p="hook/sign-message",Po="walletProviderStatus",Za="transactionsSigned",Ep=500,wr="mvx",Sp=["mvx_signTransaction","mvx_signTransactions","mvx_signMessage"],Ip={SIGN_TRANSACTIONS_REQUEST:"SIGN_TRANSACTIONS_RESPONSE",GUARD_TRANSACTIONS_REQUEST:"GUARD_TRANSACTIONS_RESPONSE",SIGN_MESSAGE_REQUEST:"SIGN_MESSAGE_RESPONSE",LOGIN_REQUEST:"LOGIN_RESPONSE",LOGOUT_REQUEST:"DISCONNECT_RESPONSE",CANCEL_ACTION_REQUEST:"CANCEL_RESPONSE",FINALIZE_HANDSHAKE_REQUEST:"NONE_RESPONSE",FINALIZE_RESET_STATE_REQUEST:"RESET_STATE_RESPONSE"};var Ro=class{constructor(e){this.nonce=BigInt(e.nonce?.valueOf()||0n),this.value=e.value??0n,this.sender=this.addressAsBech32(e.sender),this.receiver=this.addressAsBech32(e.receiver),this.senderUsername=e.senderUsername||"",this.receiverUsername=e.receiverUsername||"",this.gasPrice=BigInt(e.gasPrice?.valueOf()||lp),this.gasLimit=BigInt(e.gasLimit.valueOf()),this.data=e.data?.valueOf()||new Uint8Array,this.chainID=e.chainID.valueOf(),this.version=Number(e.version?.valueOf()||Qa),this.options=Number(e.options?.valueOf()||pp),this.guardian=e.guardian?this.addressAsBech32(e.guardian):"",this.signature=e.signature||new Uint8Array([]),this.guardianSignature=e.guardianSignature||new Uint8Array([])}addressAsBech32(e){return e}isGuardedTransaction(){let e=this.guardian.length>0,t=this.guardianSignature.length>0;return e&&t}};var xr=class extends Error{constructor(t,i){super(t);this.inner=void 0;this.inner=i}summary(){let t=[];t.push({name:this.name,message:this.message});let i=this.inner;for(;i;)t.push({name:i.name,message:i.message}),i=i.inner;return t}};var ec=class extends xr{constructor(){super("Async timer already running")}},tc=class extends xr{constructor(){super("Async timer aborted")}};var ps=class extends xr{constructor(){super("Expected transaction status not reached")}},No=class extends xr{constructor(){super("Expected transaction events not found")}};var rc=class extends xr{constructor(){super("The transaction watcher requires the `isCompleted` property to be defined on the transaction object. Perhaps you've used the sdk-network-provider's `ProxyNetworkProvider.getTransaction()` and in that case you should also pass `withProcessStatus=true`.")}};var ic=class extends xr{constructor(){super("Cannot sign single transaction.")}},nc=class extends xr{constructor(){super("Account is not connected.")}},Do=class extends Error{constructor(){super("Cannot get signed transaction(s)")}},sc=class extends Error{constructor(){super("Cannot get signed message")}};var gs=class{constructor(e){this.timeoutHandle=null;this.rejectionFunc=null;this.name=e,this.correlationTag=0}start(e){if(this.timeoutHandle)throw new ec;return this.correlationTag++,new Promise((t,i)=>{this.rejectionFunc=i;let n=()=>{this.rejectionFunc=null,this.stop(),t()};this.timeoutHandle=setTimeout(n,e)})}abort(){this.rejectionFunc&&(this.rejectionFunc(new tc),this.rejectionFunc=null),this.stop()}stop(){this.isStopped()||this.timeoutHandle&&(clearTimeout(this.timeoutHandle),this.timeoutHandle=null)}isStopped(){return!this.timeoutHandle}};var $u=class{constructor(e){this.fetcher=e}async getTransaction(e){return await this.fetcher.getTransaction(e)}},Co=class r{static{this.DefaultPollingInterval=6e3}static{this.DefaultTimeout=r.DefaultPollingInterval*15}static{this.DefaultPatience=0}static{this.NoopOnStatusReceived=()=>{}}constructor(e,t={}){this.fetcher=new $u(e),this.pollingIntervalMilliseconds=t.pollingIntervalMilliseconds||r.DefaultPollingInterval,this.timeoutMilliseconds=t.timeoutMilliseconds||r.DefaultTimeout,this.patienceMilliseconds=t.patienceMilliseconds||r.DefaultPatience}async awaitPending(e){let t=s=>s.status.isPending(),i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ps;return this.awaitConditionally(t,i,n)}async awaitCompleted(e){let t=s=>{if(s.isCompleted===void 0)throw new rc;return s.isCompleted},i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ps;return this.awaitConditionally(t,i,n)}async awaitAllEvents(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.every(u=>a.includes(u))},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new No;return this.awaitConditionally(i,n,s)}async awaitAnyEvent(e,t){let i=o=>{let a=this.getAllTransactionEvents(o).map(u=>u.identifier);return t.find(u=>a.includes(u))!=null},n=async()=>{let o=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(o)},s=()=>new No;return this.awaitConditionally(i,n,s)}async awaitOnCondition(e,t){let i=async()=>{let s=this.transactionOrTxHashToTxHash(e);return await this.fetcher.getTransaction(s)},n=()=>new ps;return this.awaitConditionally(t,i,n)}transactionOrTxHashToTxHash(e){let t=typeof e=="string"?e:e.getHash().hex();if(t.length!==Vu)throw new xr(`Invalid transaction hash length. The length of a hex encoded hash should be ${Vu}.`);return t}async awaitConditionally(e,t,i){let n=new gs("watcher:periodic"),s=new gs("watcher:patience"),o=new gs("watcher:timeout"),a=!1,f,u=!1;for(o.start(this.timeoutMilliseconds).finally(()=>{o.stop(),a=!0});!a&&(await n.start(this.pollingIntervalMilliseconds),f=await t(),u=e(f),!(u||a)););if(u&&await s.start(this.patienceMilliseconds),o.isStopped()||o.stop(),!f||!u)throw i();return f}getAllTransactionEvents(e){let t=[...e.logs.events];for(let i of e.contractResults.items)t.push(...i.logs.events);return t}};var Gt=class{constructor(e){this.data=e.data,this.signature=e.signature,this.address=e.address,this.version=e.version||mp,this.signer=e.signer||bp}};var yt=class{static transactionToPlainObject(e){return{nonce:Number(e.nonce),value:e.value.toString(),receiver:e.receiver,sender:e.sender,senderUsername:e.senderUsername?Ki(e.senderUsername):void 0,receiverUsername:e.receiverUsername?Ki(e.receiverUsername):void 0,gasPrice:Number(e.gasPrice),gasLimit:Number(e.gasLimit),data:e.data&&e.data.length?Ki(e.data):void 0,chainID:e.chainID,version:e.version,options:e.options==0?void 0:e.options,guardian:e.guardian?e.guardian:void 0,signature:e.signature&&e.signature.length?yr(e.signature):void 0,guardianSignature:e.guardianSignature&&e.guardianSignature.length?yr(e.guardianSignature):void 0}}static plainObjectToTransaction(e){return new Ro({nonce:BigInt(e.nonce),value:BigInt(e.value||""),receiver:e.receiver,receiverUsername:Mo(e.receiverUsername||""),sender:e.sender,senderUsername:Mo(e.senderUsername||""),guardian:e.guardian,gasPrice:BigInt(e.gasPrice),gasLimit:BigInt(e.gasLimit),data:e.data?On(e.data):void 0,chainID:e.chainID,version:Number(e.version),options:Number(e.options),signature:e.signature?or(e.signature):void 0,guardianSignature:e.guardianSignature?or(e.guardianSignature):void 0})}};var Ln=class r{constructor(){this.account={address:""};this.initialized=!1;if(r._instance)throw new Error("Error: Instantiation failed: Use ExtensionProvider.getInstance() instead of new.");r._instance=this}static{this._instance=new r}static getInstance(){return r._instance}setAddress(e){return this.account.address=e,r._instance}async init(){return window&&window.elrondWallet&&(this.initialized=!0),this.initialized}async login(e={}){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");let{token:t}=e,i=t||"";return await this.startBgrMsgChannel("connect",i),this.account}async logout(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");try{await this.startBgrMsgChannel("logout",this.account.address),this.disconnect()}catch(e){console.warn("Extension origin url is already cleared!",e)}return!0}disconnect(){this.account={address:""}}async getAddress(){if(!this.initialized)throw new Error("Extension provider is not initialised, call init() first");return this.account?this.account.address:""}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}async signTransaction(e){this.ensureConnected();let t=await this.signTransactions([e]);if(t.length!=1)throw new ic;return t[0]}ensureConnected(){if(!this.account.address)throw new nc}async signTransactions(e){this.ensureConnected();let t=await this.startBgrMsgChannel("signTransactions",{from:this.account.address,transactions:e.map(i=>yt.transactionToPlainObject(i))});try{return t.map(n=>yt.plainObjectToTransaction(n))}catch(i){throw new Error(`Transaction canceled: ${i.message}.`)}}async signMessage(e){this.ensureConnected();let t={account:this.account.address,message:ji(e.data)},n=(await this.startBgrMsgChannel("signMessage",t)).signature,s=or(n);return new Gt({data:e.data,address:e.address??this.account.address,signer:"extension",version:e.version,signature:s})}cancelAction(){return this.startBgrMsgChannel("cancelAction",{})}startBgrMsgChannel(e,t){return new Promise(i=>{window.postMessage({target:"erdw-inpage",type:e,data:t},window.origin);let n=s=>{s.isTrusted&&s.data.target==="erdw-contentScript"&&(s.data.type==="connectResponse"?(s.data.data&&s.data.data.address&&(this.account=s.data.data),window.removeEventListener("message",n),i(s.data.data)):(window.removeEventListener("message",n),i(s.data.data)))};window.addEventListener("message",n,!1)})}};var oc="elvenjs_state",Ap="https://devnet-api.multiversx.com";var Vi="/dapp/init",ac="devnet",Mp="https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/",Tp=["wss://relay.walletconnect.com"],At={devnet:{id:"devnet",shortId:"D",name:"Devnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://devnet-wallet.multiversx.com",xAliasAddress:"https://devnet.xalias.com",apiAddress:"https://devnet-api.multiversx.com",explorerAddress:"https://devnet-explorer.multiversx.com",apiTimeout:1e4},testnet:{id:"testnet",shortId:"T",name:"Testnet",egldLabel:"xEGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://testnet-wallet.multiversx.com",xAliasAddress:"https://testnet.xalias.com",apiAddress:"https://testnet-api.multiversx.com",explorerAddress:"https://testnet-explorer.multiversx.com",apiTimeout:1e4},mainnet:{id:"mainnet",shortId:"1",name:"Mainnet",egldLabel:"EGLD",egldDenomination:"18",decimals:"4",gasPerDataByte:"1500",walletAddress:"https://wallet.multiversx.com",xAliasAddress:"https://xalias.com",apiAddress:"https://api.multiversx.com",explorerAddress:"https://explorer.multiversx.com",apiTimeout:1e4}};var re={get(r){let e=localStorage.getItem(oc);if(!e)return{};let t=JSON.parse(e);return r?t[r]:t},set(r,e){let t=this.get();t[r]=e,localStorage.setItem(oc,JSON.stringify(t))},clear(){localStorage.removeItem(oc)}};var cc=async()=>{let r=Ln.getInstance();try{let e=await r.init(),t=re.get();if(t?.address&&r.setAddress(t.address),!e){console.warn("Something went wrong when trying to initialize the ExtensionProvider..");return}return r}catch{console.warn("Can't initialize the Dapp Provider!")}};var Bi=Be(Fn());var Qp=Be(Fn()),vc=Be(_s());var _r=class{};var Zu=class extends _r{constructor(e){super()}},Xp=vc.FIVE_SECONDS,Un={pulse:"heartbeat_pulse"},bc=class r extends Zu{constructor(e){super(e),this.events=new Qp.EventEmitter,this.interval=Xp,this.interval=e?.interval||Xp}static async init(e){let t=new r(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,vc.toMiliseconds)(this.interval))}pulse(){this.events.emit(Un.pulse)}};var R6=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,N6=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,D6=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function C6(r,e){if(r==="__proto__"||r==="constructor"&&e&&typeof e=="object"&&"prototype"in e){O6(r);return}return e}function O6(r){console.warn(`[destr] Dropping "${r}" key to prevent prototype pollution.`)}function Fo(r,e={}){if(typeof r!="string")return r;let t=r.trim();if(r[0]==='"'&&r.endsWith('"')&&!r.includes("\\"))return t.slice(1,-1);if(t.length<=9){let i=t.toLowerCase();if(i==="true")return!0;if(i==="false")return!1;if(i==="undefined")return;if(i==="null")return null;if(i==="nan")return Number.NaN;if(i==="infinity")return Number.POSITIVE_INFINITY;if(i==="-infinity")return Number.NEGATIVE_INFINITY}if(!D6.test(r)){if(e.strict)throw new SyntaxError("[destr] Invalid JSON");return r}try{if(R6.test(r)||N6.test(r)){if(e.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(r,C6)}return JSON.parse(r)}catch(i){if(e.strict)throw i;return r}}function L6(r){return!r||typeof r.then!="function"?Promise.resolve(r):r}function dt(r,...e){try{return L6(r(...e))}catch(t){return Promise.reject(t)}}function F6(r){let e=typeof r;return r===null||e!=="object"&&e!=="function"}function U6(r){let e=Object.getPrototypeOf(r);return!e||e.isPrototypeOf(Object)}function Uo(r){if(F6(r))return String(r);if(U6(r)||Array.isArray(r))return JSON.stringify(r);if(typeof r.toJSON=="function")return Uo(r.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Zp(){if(typeof Buffer>"u")throw new TypeError("[unstorage] Buffer is not supported!")}var eh="base64:";function eg(r){if(typeof r=="string")return r;Zp();let e=Buffer.from(r).toString("base64");return eh+e}function tg(r){return typeof r!="string"||!r.startsWith(eh)?r:(Zp(),Buffer.from(r.slice(eh.length),"base64"))}function Bt(r){return r?r.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function rg(...r){return Bt(r.join(":"))}function qo(r){return r=Bt(r),r?r+":":""}var q6="memory",B6=()=>{let r=new Map;return{name:q6,getInstance:()=>r,hasItem(e){return r.has(e)},getItem(e){return r.get(e)??null},getItemRaw(e){return r.get(e)??null},setItem(e,t){r.set(e,t)},setItemRaw(e,t){r.set(e,t)},removeItem(e){r.delete(e)},getKeys(){return[...r.keys()]},clear(){r.clear()},dispose(){r.clear()}}};function sg(r={}){let e={mounts:{"":r.driver||B6()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=u=>{for(let g of e.mountpoints)if(u.startsWith(g))return{base:g,relativeKey:u.slice(g.length),driver:e.mounts[g]};return{base:"",relativeKey:u,driver:e.mounts[""]}},i=(u,g)=>e.mountpoints.filter(y=>y.startsWith(u)||g&&u.startsWith(y)).map(y=>({relativeBase:u.length>y.length?u.slice(y.length):void 0,mountpoint:y,driver:e.mounts[y]})),n=(u,g)=>{if(e.watching){g=Bt(g);for(let y of e.watchListeners)y(u,g)}},s=async()=>{if(!e.watching){e.watching=!0;for(let u in e.mounts)e.unwatch[u]=await ig(e.mounts[u],n,u)}},o=async()=>{if(e.watching){for(let u in e.unwatch)await e.unwatch[u]();e.unwatch={},e.watching=!1}},a=(u,g,y)=>{let S=new Map,I=A=>{let P=S.get(A.base);return P||(P={driver:A.driver,base:A.base,items:[]},S.set(A.base,P)),P};for(let A of u){let P=typeof A=="string",O=Bt(P?A:A.key),N=P?void 0:A.value,U=P||!A.options?g:{...g,...A.options},k=t(O);I(k).items.push({key:O,value:N,relativeKey:k.relativeKey,options:U})}return Promise.all([...S.values()].map(A=>y(A))).then(A=>A.flat())},f={hasItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.hasItem,y,g)},getItem(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return dt(S.getItem,y,g).then(I=>Fo(I))},getItems(u,g){return a(u,g,y=>y.driver.getItems?dt(y.driver.getItems,y.items.map(S=>({key:S.relativeKey,options:S.options})),g).then(S=>S.map(I=>({key:rg(y.base,I.key),value:Fo(I.value)}))):Promise.all(y.items.map(S=>dt(y.driver.getItem,S.relativeKey,S.options).then(I=>({key:S.key,value:Fo(I)})))))},getItemRaw(u,g={}){u=Bt(u);let{relativeKey:y,driver:S}=t(u);return S.getItemRaw?dt(S.getItemRaw,y,g):dt(S.getItem,y,g).then(I=>tg(I))},async setItem(u,g,y={}){if(g===void 0)return f.removeItem(u);u=Bt(u);let{relativeKey:S,driver:I}=t(u);I.setItem&&(await dt(I.setItem,S,Uo(g),y),I.watch||n("update",u))},async setItems(u,g){await a(u,g,async y=>{if(y.driver.setItems)return dt(y.driver.setItems,y.items.map(S=>({key:S.relativeKey,value:Uo(S.value),options:S.options})),g);y.driver.setItem&&await Promise.all(y.items.map(S=>dt(y.driver.setItem,S.relativeKey,Uo(S.value),S.options)))})},async setItemRaw(u,g,y={}){if(g===void 0)return f.removeItem(u,y);u=Bt(u);let{relativeKey:S,driver:I}=t(u);if(I.setItemRaw)await dt(I.setItemRaw,S,g,y);else if(I.setItem)await dt(I.setItem,S,eg(g),y);else return;I.watch||n("update",u)},async removeItem(u,g={}){typeof g=="boolean"&&(g={removeMeta:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u);S.removeItem&&(await dt(S.removeItem,y,g),(g.removeMeta||g.removeMata)&&await dt(S.removeItem,y+"$",g),S.watch||n("remove",u))},async getMeta(u,g={}){typeof g=="boolean"&&(g={nativeOnly:g}),u=Bt(u);let{relativeKey:y,driver:S}=t(u),I=Object.create(null);if(S.getMeta&&Object.assign(I,await dt(S.getMeta,y,g)),!g.nativeOnly){let A=await dt(S.getItem,y+"$",g).then(P=>Fo(P));A&&typeof A=="object"&&(typeof A.atime=="string"&&(A.atime=new Date(A.atime)),typeof A.mtime=="string"&&(A.mtime=new Date(A.mtime)),Object.assign(I,A))}return I},setMeta(u,g,y={}){return this.setItem(u+"$",g,y)},removeMeta(u,g={}){return this.removeItem(u+"$",g)},async getKeys(u,g={}){u=qo(u);let y=i(u,!0),S=[],I=[];for(let A of y){let P=await dt(A.driver.getKeys,A.relativeBase,g);for(let O of P){let N=A.mountpoint+Bt(O);S.some(U=>N.startsWith(U))||I.push(N)}S=[A.mountpoint,...S.filter(O=>!O.startsWith(A.mountpoint))]}return u?I.filter(A=>A.startsWith(u)&&A[A.length-1]!=="$"):I.filter(A=>A[A.length-1]!=="$")},async clear(u,g={}){u=qo(u),await Promise.all(i(u,!1).map(async y=>{if(y.driver.clear)return dt(y.driver.clear,y.relativeBase,g);if(y.driver.removeItem){let S=await y.driver.getKeys(y.relativeBase||"",g);return Promise.all(S.map(I=>y.driver.removeItem(I,g)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(u=>ng(u)))},async watch(u){return await s(),e.watchListeners.push(u),async()=>{e.watchListeners=e.watchListeners.filter(g=>g!==u),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(u,g){if(u=qo(u),u&&e.mounts[u])throw new Error(`already mounted at ${u}`);return u&&(e.mountpoints.push(u),e.mountpoints.sort((y,S)=>S.length-y.length)),e.mounts[u]=g,e.watching&&Promise.resolve(ig(g,n,u)).then(y=>{e.unwatch[u]=y}).catch(console.error),f},async unmount(u,g=!0){u=qo(u),!(!u||!e.mounts[u])&&(e.watching&&u in e.unwatch&&(e.unwatch[u](),delete e.unwatch[u]),g&&await ng(e.mounts[u]),e.mountpoints=e.mountpoints.filter(y=>y!==u),delete e.mounts[u])},getMount(u=""){u=Bt(u)+":";let g=t(u);return{driver:g.driver,base:g.base}},getMounts(u="",g={}){return u=Bt(u),i(u,g.parents).map(S=>({driver:S.driver,base:S.mountpoint}))},keys:(u,g={})=>f.getKeys(u,g),get:(u,g={})=>f.getItem(u,g),set:(u,g,y={})=>f.setItem(u,g,y),has:(u,g={})=>f.hasItem(u,g),del:(u,g={})=>f.removeItem(u,g),remove:(u,g={})=>f.removeItem(u,g)};return f}function ig(r,e,t){return r.watch?r.watch((i,n)=>e(i,t+n)):()=>{}}async function ng(r){typeof r.dispose=="function"&&await dt(r.dispose)}function qn(r){return new Promise((e,t)=>{r.oncomplete=r.onsuccess=()=>e(r.result),r.onabort=r.onerror=()=>t(r.error)})}function rh(r,e){let t=indexedDB.open(r);t.onupgradeneeded=()=>t.result.createObjectStore(e);let i=qn(t);return(n,s)=>i.then(o=>s(o.transaction(e,n).objectStore(e)))}var th;function Bo(){return th||(th=rh("keyval-store","keyval")),th}function ih(r,e=Bo()){return e("readonly",t=>qn(t.get(r)))}function og(r,e,t=Bo()){return t("readwrite",i=>(i.put(e,r),qn(i.transaction)))}function ag(r,e=Bo()){return e("readwrite",t=>(t.delete(r),qn(t.transaction)))}function cg(r=Bo()){return r("readwrite",e=>(e.clear(),qn(e.transaction)))}function k6(r,e){return r.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},qn(r.transaction)}function fg(r=Bo()){return r("readonly",e=>{if(e.getAllKeys)return qn(e.getAllKeys());let t=[];return k6(e,i=>t.push(i.key)).then(()=>t)})}var z6=r=>JSON.stringify(r,(e,t)=>typeof t=="bigint"?t.toString()+"n":t),j6=r=>{let e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,t=r.replace(e,'$1"$2n"$3');return JSON.parse(t,(i,n)=>typeof n=="string"&&n.match(/^\d+n$/)?BigInt(n.substring(0,n.length-1)):n)};function Qr(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return j6(r)}catch{return r}}function ar(r){return typeof r=="string"?r:z6(r)||""}var K6="idb-keyval",V6=(r={})=>{let e=r.base&&r.base.length>0?`${r.base}:`:"",t=n=>e+n,i;return r.dbName&&r.storeName&&(i=rh(r.dbName,r.storeName)),{name:K6,options:r,async hasItem(n){return!(typeof await ih(t(n),i)>"u")},async getItem(n){return await ih(t(n),i)??null},setItem(n,s){return og(t(n),s,i)},removeItem(n){return ag(t(n),i)},getKeys(){return fg(i)},clear(){return cg(i)}}},$6="WALLET_CONNECT_V2_INDEXED_DB",H6="keyvaluestorage",sh=class{constructor(){this.indexedDb=sg({driver:V6({dbName:$6,storeName:H6})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,ar(t))}async removeItem(e){await this.indexedDb.removeItem(e)}},nh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},yc={exports:{}};(function(){let r;function e(){}r=e,r.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},r.prototype.setItem=function(t,i){this[t]=String(i)},r.prototype.removeItem=function(t){delete this[t]},r.prototype.clear=function(){let t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},r.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},r.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof nh<"u"&&nh.localStorage?yc.exports=nh.localStorage:typeof window<"u"&&window.localStorage?yc.exports=window.localStorage:yc.exports=new e})();function G6(r){var e;return[r[0],Qr((e=r[1])!=null?e:"")]}var oh=class{constructor(){this.localStorage=yc.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(G6)}async getItem(e){let t=this.localStorage.getItem(e);if(t!==null)return Qr(t)}async setItem(e,t){this.localStorage.setItem(e,ar(t))}async removeItem(e){this.localStorage.removeItem(e)}},W6="wc_storage_version",ug=1,J6=async(r,e,t)=>{let i=W6,n=await e.getItem(i);if(n&&n>=ug){t(e);return}let s=await r.getKeys();if(!s.length){t(e);return}let o=[];for(;s.length;){let a=s.shift();if(!a)continue;let f=a.toLowerCase();if(f.includes("wc@")||f.includes("walletconnect")||f.includes("wc_")||f.includes("wallet_connect")){let u=await r.getItem(a);await e.setItem(a,u),o.push(a)}}await e.setItem(i,ug),t(e),Y6(r,o)},Y6=async(r,e)=>{e.length&&e.forEach(async t=>{await r.removeItem(t)})},wc=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};let e=new oh;this.storage=e;try{let t=new sh;J6(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var Ei=Be(fh()),jo=Be(fh());var f5={level:"info"},Ko="custom_context",lh=1e3*1024,uh=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Ec=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new uh(e);if(t.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;t!==null;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}},Sc=class{constructor(e,t=lh){this.level=e??"error",this.levelValue=Ei.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new Ec(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===Ei.levels.values.error?console.error(e):t===Ei.levels.values.warn?console.warn(e):t===Ei.levels.values.debug?console.debug(e):t===Ei.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(ar({timestamp:new Date().toISOString(),log:e}));let t=typeof e=="string"?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new Ec(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push(ar({extraMetadata:e})),new Blob(t,{type:"application/json"})}},hh=class{constructor(e,t=lh){this.baseChunkLogger=new Sc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}},dh=class{constructor(e,t=lh){this.baseChunkLogger=new Sc(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}},u5=Object.defineProperty,h5=Object.defineProperties,d5=Object.getOwnPropertyDescriptors,bg=Object.getOwnPropertySymbols,l5=Object.prototype.hasOwnProperty,p5=Object.prototype.propertyIsEnumerable,vg=(r,e,t)=>e in r?u5(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ic=(r,e)=>{for(var t in e||(e={}))l5.call(e,t)&&vg(r,t,e[t]);if(bg)for(var t of bg(e))p5.call(e,t)&&vg(r,t,e[t]);return r},Ac=(r,e)=>h5(r,d5(e));function Vo(r){return Ac(Ic({},r),{level:r?.level||f5.level})}function g5(r,e=Ko){return r[e]||""}function m5(r,e,t=Ko){return r[t]=e,r}function Mt(r,e=Ko){let t="";return typeof r.bindings>"u"?t=g5(r,e):t=r.bindings().context||"",t}function b5(r,e,t=Ko){let i=Mt(r,t);return i.trim()?`${i}/${e}`:e}function wt(r,e,t=Ko){let i=b5(r,e,t),n=r.child({context:i});return m5(n,i,t)}function v5(r){var e,t;let i=new hh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ei.default)(Ac(Ic({},r.opts),{level:"trace",browser:Ac(Ic({},(t=r.opts)==null?void 0:t.browser),{write:n=>i.write(n)})})),chunkLoggerController:i}}function y5(r){var e;let t=new dh((e=r.opts)==null?void 0:e.level,r.maxSizeInBytes);return{logger:(0,Ei.default)(Ac(Ic({},r.opts),{level:"trace"}),t),chunkLoggerController:t}}function yg(r){return typeof r.loggerOverride<"u"&&typeof r.loggerOverride!="string"?{logger:r.loggerOverride,chunkLoggerController:null}:typeof window<"u"?v5(r):y5(r)}var wg=Be(Fn()),Mc=class extends _r{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}};var Tc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}},Pc=class{constructor(e,t){this.logger=e,this.core=t}},Rc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}},Nc=class extends _r{constructor(e){super()}},Dc=class{constructor(e,t,i,n){this.core=e,this.logger=t,this.name=i}};var Cc=class extends _r{constructor(e,t){super(),this.relayer=e,this.logger=t}};var Oc=class extends _r{constructor(e,t){super(),this.core=e,this.logger=t}};var Lc=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Fc=class{constructor(e,t){this.projectId=e,this.logger=t}},Uc=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var qc=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}};var Bc=class{constructor(e){this.client=e}};var ne=Be(_s());var ta=Be(Yg()),M1=Be($o()),T1=Be(_s());var Xg="EdDSA",Qg="JWT",Wo=".",Jo="base64url",Dh="utf8",Ch="utf8",Zg=":",e1="did",t1="key",Oh="base58btc",r1="z",i1="K36";function Yo(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function jn(r,e){e||(e=r.reduce((n,s)=>n+s.length,0));let t=Yo(e),i=0;for(let n of r)t.set(n,i),i+=n.length;return t}var Bh={};qt(Bh,{identity:()=>yx});function px(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var C=k-O;C!==k&&B[C]===0;)C++;for(var W=f.repeat(P);C>>0,k=new Uint8Array(U);A[P];){var B=t[A.charCodeAt(P)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,P++}if(A[P]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var C=new Uint8Array(O+(U-L)),W=O;L!==U;)C[W++]=k[L++];return C}}}function I(A){var P=S(A);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var gx=px,mx=gx,n1=mx;var pR=new Uint8Array(0);var s1=(r,e)=>{if(r===e)return!0;if(r.byteLength!==e.byteLength)return!1;for(let t=0;t{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")};var o1=r=>new TextEncoder().encode(r),a1=r=>new TextDecoder().decode(r);var Lh=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Fh=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return f1(this,e)}},Uh=class{constructor(e){this.decoders=e}or(e){return f1(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},f1=(r,e)=>new Uh({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),qh=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Lh(e,t,i),this.decoder=new Fh(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},Ps=({name:r,prefix:e,encode:t,decode:i})=>new qh(r,e,t,i),Hi=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=n1(t,e);return Ps({prefix:r,name:e,encode:i,decode:s=>Ii(n(s))})},bx=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},vx=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<Ps({prefix:e,name:r,encode(n){return vx(n,i,t)},decode(n){return bx(n,i,t,r)}});var yx=Ps({prefix:"\0",name:"identity",encode:r=>a1(r),decode:r=>o1(r)});var kh={};qt(kh,{base2:()=>wx});var wx=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var zh={};qt(zh,{base8:()=>xx});var xx=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var jh={};qt(jh,{base10:()=>_x});var _x=Hi({prefix:"9",name:"base10",alphabet:"0123456789"});var Kh={};qt(Kh,{base16:()=>Ex,base16upper:()=>Sx});var Ex=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Sx=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Vh={};qt(Vh,{base32:()=>Rs,base32hex:()=>Tx,base32hexpad:()=>Rx,base32hexpadupper:()=>Nx,base32hexupper:()=>Px,base32pad:()=>Ax,base32padupper:()=>Mx,base32upper:()=>Ix,base32z:()=>Dx});var Rs=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ix=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ax=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mx=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Tx=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Px=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Rx=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Nx=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Dx=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $h={};qt($h,{base36:()=>Cx,base36upper:()=>Ox});var Cx=Hi({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Ox=Hi({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Hh={};qt(Hh,{base58btc:()=>ei,base58flickr:()=>Lx});var ei=Hi({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lx=Hi({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Gh={};qt(Gh,{base64:()=>Fx,base64pad:()=>Ux,base64url:()=>qx,base64urlpad:()=>Bx});var Fx=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Ux=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qx=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Bx=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Wh={};qt(Wh,{base256emoji:()=>Vx});var u1=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),kx=u1.reduce((r,e,t)=>(r[t]=e,r),[]),zx=u1.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function jx(r){return r.reduce((e,t)=>(e+=kx[t],e),"")}function Kx(r){let e=[];for(let t of r){let i=zx[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var Vx=Ps({prefix:"\u{1F680}",name:"base256emoji",encode:jx,decode:Kx});var Qh={};qt(Qh,{sha256:()=>f4,sha512:()=>u4});var $x=l1,h1=128,Hx=127,Gx=~Hx,Wx=Math.pow(2,31);function l1(r,e,t){e=e||[],t=t||0;for(var i=t;r>=Wx;)e[t++]=r&255|h1,r/=128;for(;r&Gx;)e[t++]=r&255|h1,r>>>=7;return e[t]=r|0,l1.bytes=t-i+1,e}var Jx=Jh,Yx=128,d1=127;function Jh(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw Jh.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&d1)<=Yx);return Jh.bytes=s-i,t}var Xx=Math.pow(2,7),Qx=Math.pow(2,14),Zx=Math.pow(2,21),e4=Math.pow(2,28),t4=Math.pow(2,35),r4=Math.pow(2,42),i4=Math.pow(2,49),n4=Math.pow(2,56),s4=Math.pow(2,63),o4=function(r){return r[Xo.decode(r,e),Xo.decode.bytes],Ns=(r,e,t=0)=>(Xo.encode(r,e,t),e),Ds=r=>Xo.encodingLength(r);var Kn=(r,e)=>{let t=e.byteLength,i=Ds(r),n=i+Ds(t),s=new Uint8Array(n+t);return Ns(r,s,0),Ns(t,s,i),s.set(e,n),new Cs(r,t,e,s)},p1=r=>{let e=Ii(r),[t,i]=Qo(e),[n,s]=Qo(e.subarray(i)),o=e.subarray(i+s);if(o.byteLength!==n)throw new Error("Incorrect length");return new Cs(t,n,o,e)},g1=(r,e)=>r===e?!0:r.code===e.code&&r.size===e.size&&s1(r.bytes,e.bytes),Cs=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}};var Xh=({name:r,code:e,encode:t})=>new Yh(r,e,t),Yh=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Kn(this.code,t):t.then(i=>Kn(this.code,i))}else throw Error("Unknown type, must be binary type")}};var b1=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),f4=Xh({name:"sha2-256",code:18,encode:b1("SHA-256")}),u4=Xh({name:"sha2-512",code:19,encode:b1("SHA-512")});var Zh={};qt(Zh,{identity:()=>l4});var v1=0,h4="identity",y1=Ii,d4=r=>Kn(v1,y1(r)),l4={code:v1,name:h4,encode:y1,digest:d4};var LR=new TextEncoder,FR=new TextDecoder;var Wc=class r{constructor(e,t,i,n){this.code=t,this.version=e,this.multihash=i,this.bytes=n,this.byteOffset=n.byteOffset,this.byteLength=n.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:Gc,byteLength:Gc,code:Hc,version:Hc,multihash:Hc,bytes:Hc,_baseCache:Gc,asCID:Gc})}toV0(){switch(this.version){case 0:return this;default:{let{code:e,multihash:t}=this;if(e!==ea)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(t.code!==y4)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return r.createV0(t)}}}toV1(){switch(this.version){case 0:{let{code:e,digest:t}=this.multihash,i=Kn(e,t);return r.createV1(this.code,i)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(e){return e&&this.code===e.code&&this.version===e.version&&g1(this.multihash,e.multihash)}toString(e){let{bytes:t,version:i,_baseCache:n}=this;switch(i){case 0:return b4(t,n,e||ei.encoder);default:return v4(t,n,e||Rs.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(e){return x4(/^0\.0/,_4),!!(e&&(e[x1]||e.asCID===e))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(e){if(e instanceof r)return e;if(e!=null&&e.asCID===e){let{version:t,code:i,multihash:n,bytes:s}=e;return new r(t,i,n,s||w1(t,i,n.bytes))}else if(e!=null&&e[x1]===!0){let{version:t,multihash:i,code:n}=e,s=p1(i);return r.create(t,n,s)}else return null}static create(e,t,i){if(typeof t!="number")throw new Error("String codecs are no longer supported");switch(e){case 0:{if(t!==ea)throw new Error(`Version 0 CID must use dag-pb (code: ${ea}) block encoding`);return new r(e,t,i,i.bytes)}case 1:{let n=w1(e,t,i.bytes);return new r(e,t,i,n)}default:throw new Error("Invalid version")}}static createV0(e){return r.create(0,ea,e)}static createV1(e,t){return r.create(1,e,t)}static decode(e){let[t,i]=r.decodeFirst(e);if(i.length)throw new Error("Incorrect length");return t}static decodeFirst(e){let t=r.inspectBytes(e),i=t.size-t.multihashSize,n=Ii(e.subarray(i,i+t.multihashSize));if(n.byteLength!==t.multihashSize)throw new Error("Incorrect length");let s=n.subarray(t.multihashSize-t.digestSize),o=new Cs(t.multihashCode,t.digestSize,s,n);return[t.version===0?r.createV0(o):r.createV1(t.codec,o),e.subarray(t.size)]}static inspectBytes(e){let t=0,i=()=>{let[y,S]=Qo(e.subarray(t));return t+=S,y},n=i(),s=ea;if(n===18?(n=0,t=0):n===1&&(s=i()),n!==0&&n!==1)throw new RangeError(`Invalid CID version ${n}`);let o=t,a=i(),f=i(),u=t+f,g=u-o;return{version:n,codec:s,multihashCode:a,digestSize:f,multihashSize:g,size:u}}static parse(e,t){let[i,n]=m4(e,t),s=r.decode(n);return s._baseCache.set(i,e),s}},m4=(r,e)=>{switch(r[0]){case"Q":{let t=e||ei;return[ei.prefix,t.decode(`${ei.prefix}${r}`)]}case ei.prefix:{let t=e||ei;return[ei.prefix,t.decode(r)]}case Rs.prefix:{let t=e||Rs;return[Rs.prefix,t.decode(r)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[r[0],e.decode(r)]}}},b4=(r,e,t)=>{let{prefix:i}=t;if(i!==ei.prefix)throw Error(`Cannot string encode V0 in ${t.name} encoding`);let n=e.get(i);if(n==null){let s=t.encode(r).slice(1);return e.set(i,s),s}else return n},v4=(r,e,t)=>{let{prefix:i}=t,n=e.get(i);if(n==null){let s=t.encode(r);return e.set(i,s),s}else return n},ea=112,y4=18,w1=(r,e,t)=>{let i=Ds(r),n=i+Ds(e),s=new Uint8Array(n+t.byteLength);return Ns(r,s,0),Ns(e,s,i),s.set(t,n),s},x1=Symbol.for("@ipld/js-cid/CID"),Hc={writable:!1,configurable:!1,enumerable:!0},Gc={writable:!1,enumerable:!1,configurable:!1},w4="0.0.0-dev",x4=(r,e)=>{if(r.test(w4))console.warn(e);else throw new Error(e)},_4=`CID.isCID(v) is deprecated and will be removed in the next major release. -Following code pattern: - -if (CID.isCID(value)) { - doSomethingWithCID(value) -} - -Is replaced with: - -const cid = CID.asCID(value) -if (cid) { - // Make sure to use cid instead of value - doSomethingWithCID(cid) -} -`;var ed={...Bh,...kh,...zh,...jh,...Kh,...Vh,...$h,...Hh,...Gh,...Wh},VR={...Qh,...Zh};function E1(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var _1=E1("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),td=E1("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=Yo(r.length);for(let t=0;t"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new D4:typeof navigator<"u"?C1(navigator.userAgent):q4()}function F4(r){return r!==""&&L4.reduce(function(e,t){var i=t[0],n=t[1];if(e)return e;var s=n.exec(r);return!!s&&[i,s]},!1)}function C1(r){var e=F4(r);if(!e)return null;var t=e[0],i=e[1];if(t==="searchbot")return new N4;var n=i[1]&&i[1].split(".").join("_").split("_").slice(0,3);n?n.length{try{if("test".normalize(e)!=="test")throw new Error("bad normalize")}catch{r.push(e)}}),r.length)throw new Error("missing "+r.join(", "));if("\xE9".normalize("NFD")!=="e\u0301")throw new Error("broken implementation")}catch(r){return r.message}return null}var am=o8(),od;(function(r){r.DEBUG="DEBUG",r.INFO="INFO",r.WARNING="WARNING",r.ERROR="ERROR",r.OFF="OFF"})(od||(od={}));var Er;(function(r){r.UNKNOWN_ERROR="UNKNOWN_ERROR",r.NOT_IMPLEMENTED="NOT_IMPLEMENTED",r.UNSUPPORTED_OPERATION="UNSUPPORTED_OPERATION",r.NETWORK_ERROR="NETWORK_ERROR",r.SERVER_ERROR="SERVER_ERROR",r.TIMEOUT="TIMEOUT",r.BUFFER_OVERRUN="BUFFER_OVERRUN",r.NUMERIC_FAULT="NUMERIC_FAULT",r.MISSING_NEW="MISSING_NEW",r.INVALID_ARGUMENT="INVALID_ARGUMENT",r.MISSING_ARGUMENT="MISSING_ARGUMENT",r.UNEXPECTED_ARGUMENT="UNEXPECTED_ARGUMENT",r.CALL_EXCEPTION="CALL_EXCEPTION",r.INSUFFICIENT_FUNDS="INSUFFICIENT_FUNDS",r.NONCE_EXPIRED="NONCE_EXPIRED",r.REPLACEMENT_UNDERPRICED="REPLACEMENT_UNDERPRICED",r.UNPREDICTABLE_GAS_LIMIT="UNPREDICTABLE_GAS_LIMIT",r.TRANSACTION_REPLACED="TRANSACTION_REPLACED",r.ACTION_REJECTED="ACTION_REJECTED"})(Er||(Er={}));var cm="0123456789abcdef",lt=class r{constructor(e){Object.defineProperty(this,"version",{enumerable:!0,value:e,writable:!1})}_log(e,t){let i=e.toLowerCase();tf[i]==null&&this.throwArgumentError("invalid log level name","logLevel",e),!(om>tf[i])&&console.log.apply(console,t)}debug(...e){this._log(r.levels.DEBUG,e)}info(...e){this._log(r.levels.INFO,e)}warn(...e){this._log(r.levels.WARNING,e)}makeError(e,t,i){if(sm)return this.makeError("censored error",t,{});t||(t=r.errors.UNKNOWN_ERROR),i||(i={});let n=[];Object.keys(i).forEach(f=>{let u=i[f];try{if(u instanceof Uint8Array){let g="";for(let y=0;y>4],g+=cm[u[y]&15];n.push(f+"=Uint8Array(0x"+g+")")}else n.push(f+"="+JSON.stringify(u))}catch{n.push(f+"="+JSON.stringify(i[f].toString()))}}),n.push(`code=${t}`),n.push(`version=${this.version}`);let s=e,o="";switch(t){case Er.NUMERIC_FAULT:{o="NUMERIC_FAULT";let f=e;switch(f){case"overflow":case"underflow":case"division-by-zero":o+="-"+f;break;case"negative-power":case"negative-width":o+="-unsupported";break;case"unbound-bitwise-result":o+="-unbound-result";break}break}case Er.CALL_EXCEPTION:case Er.INSUFFICIENT_FUNDS:case Er.MISSING_NEW:case Er.NONCE_EXPIRED:case Er.REPLACEMENT_UNDERPRICED:case Er.TRANSACTION_REPLACED:case Er.UNPREDICTABLE_GAS_LIMIT:o=t;break}o&&(e+=" [ See: https://links.ethers.org/v5-errors-"+o+" ]"),n.length&&(e+=" ("+n.join(", ")+")");let a=new Error(e);return a.reason=s,a.code=t,Object.keys(i).forEach(function(f){a[f]=i[f]}),a}throwError(e,t,i){throw this.makeError(e,t,i)}throwArgumentError(e,t,i){return this.throwError(e,r.errors.INVALID_ARGUMENT,{argument:t,value:i})}assert(e,t,i,n){e||this.throwError(t,i,n)}assertArgument(e,t,i,n){e||this.throwArgumentError(t,i,n)}checkNormalize(e){e==null&&(e="platform missing String.prototype.normalize"),am&&this.throwError("platform missing String.prototype.normalize",r.errors.UNSUPPORTED_OPERATION,{operation:"String.prototype.normalize",form:am})}checkSafeUint53(e,t){typeof e=="number"&&(t==null&&(t="value not safe"),(e<0||e>=9007199254740991)&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"out-of-safe-range",value:e}),e%1&&this.throwError(t,r.errors.NUMERIC_FAULT,{operation:"checkSafeInteger",fault:"non-integer",value:e}))}checkArgumentCount(e,t,i){i?i=": "+i:i="",et&&this.throwError("too many arguments"+i,r.errors.UNEXPECTED_ARGUMENT,{count:e,expectedCount:t})}checkNew(e,t){(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}checkAbstract(e,t){e===t?this.throwError("cannot instantiate abstract class "+JSON.stringify(t.name)+" directly; use a sub-class",r.errors.UNSUPPORTED_OPERATION,{name:e.name,operation:"new"}):(e===Object||e==null)&&this.throwError("missing new",r.errors.MISSING_NEW,{name:t.name})}static globalLogger(){return sd||(sd=new r(im)),sd}static setCensorship(e,t){if(!e&&t&&this.globalLogger().throwError("cannot permanently disable censorship",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"}),nm){if(!e)return;this.globalLogger().throwError("error censorship permanent",r.errors.UNSUPPORTED_OPERATION,{operation:"setCensorship"})}sm=!!e,nm=!!t}static setLogLevel(e){let t=tf[e.toLowerCase()];if(t==null){r.globalLogger().warn("invalid log level - "+e);return}om=t}static from(e){return new r(e)}};lt.errors=Er;lt.levels=od;var fm="bytes/5.7.0";var ft=new lt(fm);function hm(r){return!!r.toHexString}function Fs(r){return r.slice||(r.slice=function(){let e=Array.prototype.slice.call(arguments);return Fs(new Uint8Array(Array.prototype.slice.apply(r,e)))}),r}function dm(r){return Sr(r)&&!(r.length%2)||cd(r)}function um(r){return typeof r=="number"&&r==r&&r%1===0}function cd(r){if(r==null)return!1;if(r.constructor===Uint8Array)return!0;if(typeof r=="string"||!um(r.length)||r.length<0)return!1;for(let e=0;e=256)return!1}return!0}function Qe(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid arrayify value");let t=[];for(;r;)t.unshift(r&255),r=parseInt(String(r/256));return t.length===0&&t.push(0),Fs(new Uint8Array(t))}if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),hm(r)&&(r=r.toHexString()),Sr(r)){let t=r.substring(2);t.length%2&&(e.hexPad==="left"?t="0"+t:e.hexPad==="right"?t+="0":ft.throwArgumentError("hex data is odd-length","value",r));let i=[];for(let n=0;nQe(n)),t=e.reduce((n,s)=>n+s.length,0),i=new Uint8Array(t);return e.reduce((n,s)=>(i.set(s,n),n+s.length),0),Fs(i)}function a8(r,e){r=Qe(r),r.length>e&&ft.throwArgumentError("value out of range","value",arguments[0]);let t=new Uint8Array(e);return t.set(r,e-r.length),Fs(t)}function Sr(r,e){return!(typeof r!="string"||!r.match(/^0x[0-9A-Fa-f]*$/)||e&&r.length!==2+2*e)}var ad="0123456789abcdef";function Pt(r,e){if(e||(e={}),typeof r=="number"){ft.checkSafeUint53(r,"invalid hexlify value");let t="";for(;r;)t=ad[r&15]+t,r=Math.floor(r/16);return t.length?(t.length%2&&(t="0"+t),"0x"+t):"0x00"}if(typeof r=="bigint")return r=r.toString(16),r.length%2?"0x0"+r:"0x"+r;if(e.allowMissingPrefix&&typeof r=="string"&&r.substring(0,2)!=="0x"&&(r="0x"+r),hm(r))return r.toHexString();if(Sr(r))return r.length%2&&(e.hexPad==="left"?r="0x0"+r.substring(2):e.hexPad==="right"?r+="0":ft.throwArgumentError("hex data is odd-length","value",r)),r.toLowerCase();if(cd(r)){let t="0x";for(let i=0;i>4]+ad[n&15]}return t}return ft.throwArgumentError("invalid hexlify value","value",r)}function rf(r){if(typeof r!="string")r=Pt(r);else if(!Sr(r)||r.length%2)return null;return(r.length-2)/2}function nf(r,e,t){return typeof r!="string"?r=Pt(r):(!Sr(r)||r.length%2)&&ft.throwArgumentError("invalid hexData","value",r),e=2+2*e,t!=null?"0x"+r.substring(e,2+2*t):"0x"+r.substring(e)}function Gi(r,e){for(typeof r!="string"?r=Pt(r):Sr(r)||ft.throwArgumentError("invalid hex string","value",r),r.length>2*e+2&&ft.throwArgumentError("value out of range","value",arguments[1]);r.length<2*e+2;)r="0x0"+r.substring(2);return r}function sf(r){let e={r:"0x",s:"0x",_vs:"0x",recoveryParam:0,v:0,yParityAndS:"0x",compact:"0x"};if(dm(r)){let t=Qe(r);t.length===64?(e.v=27+(t[32]>>7),t[32]&=127,e.r=Pt(t.slice(0,32)),e.s=Pt(t.slice(32,64))):t.length===65?(e.r=Pt(t.slice(0,32)),e.s=Pt(t.slice(32,64)),e.v=t[64]):ft.throwArgumentError("invalid signature string","signature",r),e.v<27&&(e.v===0||e.v===1?e.v+=27:ft.throwArgumentError("signature invalid v byte","signature",r)),e.recoveryParam=1-e.v%2,e.recoveryParam&&(t[32]|=128),e._vs=Pt(t.slice(32,64))}else{if(e.r=r.r,e.s=r.s,e.v=r.v,e.recoveryParam=r.recoveryParam,e._vs=r._vs,e._vs!=null){let n=a8(Qe(e._vs),32);e._vs=Pt(n);let s=n[0]>=128?1:0;e.recoveryParam==null?e.recoveryParam=s:e.recoveryParam!==s&&ft.throwArgumentError("signature recoveryParam mismatch _vs","signature",r),n[0]&=127;let o=Pt(n);e.s==null?e.s=o:e.s!==o&&ft.throwArgumentError("signature v mismatch _vs","signature",r)}if(e.recoveryParam==null)e.v==null?ft.throwArgumentError("signature missing v and recoveryParam","signature",r):e.v===0||e.v===1?e.recoveryParam=e.v:e.recoveryParam=1-e.v%2;else if(e.v==null)e.v=27+e.recoveryParam;else{let n=e.v===0||e.v===1?e.v:1-e.v%2;e.recoveryParam!==n&&ft.throwArgumentError("signature recoveryParam mismatch v","signature",r)}e.r==null||!Sr(e.r)?ft.throwArgumentError("signature missing or invalid r","signature",r):e.r=Gi(e.r,32),e.s==null||!Sr(e.s)?ft.throwArgumentError("signature missing or invalid s","signature",r):e.s=Gi(e.s,32);let t=Qe(e.s);t[0]>=128&&ft.throwArgumentError("signature s out of range","signature",r),e.recoveryParam&&(t[0]|=128);let i=Pt(t);e._vs&&(Sr(e._vs)||ft.throwArgumentError("signature invalid _vs","signature",r),e._vs=Gi(e._vs,32)),e._vs==null?e._vs=i:e._vs!==i&&ft.throwArgumentError("signature _vs mismatch v and s","signature",r)}return e.yParityAndS=e._vs,e.compact=e.r+e.yParityAndS.substring(2),e}function Us(r){return"0x"+lm.default.keccak_256(Qe(r))}var mm=Be(dd());var gm="bignumber/5.7.0";var c8=mm.default.BN,UN=new lt(gm);function ld(r){return new c8(r,36).toString(16)}var bm="strings/5.7.0";var vm=new lt(bm),ra;(function(r){r.current="",r.NFC="NFC",r.NFD="NFD",r.NFKC="NFKC",r.NFKD="NFKD"})(ra||(ra={}));var $n;(function(r){r.UNEXPECTED_CONTINUE="unexpected continuation byte",r.BAD_PREFIX="bad codepoint prefix",r.OVERRUN="string overrun",r.MISSING_CONTINUE="missing continuation byte",r.OUT_OF_RANGE="out of UTF-8 range",r.UTF16_SURROGATE="UTF-16 surrogate",r.OVERLONG="overlong representation"})($n||($n={}));function u8(r,e,t,i,n){return vm.throwArgumentError(`invalid codepoint at offset ${e}; ${r}`,"bytes",t)}function ym(r,e,t,i,n){if(r===$n.BAD_PREFIX||r===$n.UNEXPECTED_CONTINUE){let s=0;for(let o=e+1;o>6===2;o++)s++;return s}return r===$n.OVERRUN?t.length-e-1:0}function h8(r,e,t,i,n){return r===$n.OVERLONG?(i.push(n),0):(i.push(65533),ym(r,e,t,i,n))}var d8=Object.freeze({error:u8,ignore:ym,replace:h8});function ia(r,e=ra.current){e!=ra.current&&(vm.checkNormalize(),r=r.normalize(e));let t=[];for(let i=0;i>6|192),t.push(n&63|128);else if((n&64512)==55296){i++;let s=r.charCodeAt(i);if(i>=r.length||(s&64512)!==56320)throw new Error("invalid utf-8 string");let o=65536+((n&1023)<<10)+(s&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(n>>12|224),t.push(n>>6&63|128),t.push(n&63|128)}return Qe(t)}var wm=`Ethereum Signed Message: -`;function of(r){return typeof r=="string"&&(r=ia(r)),Us(fd([ia(wm),ia(String(r.length)),r]))}var xm="address/5.7.0";var na=new lt(xm);function _m(r){Sr(r,20)||na.throwArgumentError("invalid address","address",r),r=r.toLowerCase();let e=r.substring(2).split(""),t=new Uint8Array(40);for(let n=0;n<40;n++)t[n]=e[n].charCodeAt(0);let i=Qe(Us(t));for(let n=0;n<40;n+=2)i[n>>1]>>4>=8&&(e[n]=e[n].toUpperCase()),(i[n>>1]&15)>=8&&(e[n+1]=e[n+1].toUpperCase());return"0x"+e.join("")}var p8=9007199254740991;function g8(r){return Math.log10?Math.log10(r):Math.log(r)/Math.LN10}var pd={};for(let r=0;r<10;r++)pd[String(r)]=String(r);for(let r=0;r<26;r++)pd[String.fromCharCode(65+r)]=String(10+r);var Em=Math.floor(g8(p8));function m8(r){r=r.toUpperCase(),r=r.substring(4)+r.substring(0,2)+"00";let e=r.split("").map(i=>pd[i]).join("");for(;e.length>=Em;){let i=e.substring(0,Em);e=parseInt(i,10)%97+e.substring(i.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}function Sm(r){let e=null;if(typeof r!="string"&&na.throwArgumentError("invalid address","address",r),r.match(/^(0x)?[0-9a-fA-F]{40}$/))r.substring(0,2)!=="0x"&&(r="0x"+r),e=_m(r),r.match(/([A-F].*[a-f])|([a-f].*[A-F])/)&&e!==r&&na.throwArgumentError("bad address checksum","address",r);else if(r.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){for(r.substring(2,4)!==m8(r)&&na.throwArgumentError("bad icap checksum","address",r),e=ld(r.substring(4));e.length<40;)e="0"+e;e=_m("0x"+e)}else na.throwArgumentError("invalid address","address",r);return e}var Im="properties/5.7.0";var dD=new lt(Im);function qs(r,e,t){Object.defineProperty(r,e,{enumerable:!0,value:t,writable:!1})}var Le=Be(dd()),ai=Be(ca());function $s(r,e,t){return t={path:e,exports:{},require:function(i,n){return B_(i,n??t.path)}},r(t,t.exports),t.exports}function B_(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Md=cb;function cb(r,e){if(!r)throw new Error(e||"Assertion failed")}cb.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)};var Tr=$s(function(r,e){"use strict";var t=e;function i(o,a){if(Array.isArray(o))return o.slice();if(!o)return[];var f=[];if(typeof o!="string"){for(var u=0;u>8,S=g&255;y?f.push(y,S):f.push(S)}return f}t.toArray=i;function n(o){return o.length===1?"0"+o:o}t.zero2=n;function s(o){for(var a="",f=0;f(S>>1)-1?P=(S>>1)-O:P=O,I.isubn(P)):P=0,y[A]=P,I.iushrn(1)}return y}t.getNAF=i;function n(f,u){var g=[[],[]];f=f.clone(),u=u.clone();for(var y=0,S=0,I;f.cmpn(-y)>0||u.cmpn(-S)>0;){var A=f.andln(3)+y&3,P=u.andln(3)+S&3;A===3&&(A=-1),P===3&&(P=-1);var O;A&1?(I=f.andln(7)+y&7,(I===3||I===5)&&P===2?O=-A:O=A):O=0,g[0].push(O);var N;P&1?(I=u.andln(7)+S&7,(I===3||I===5)&&A===2?N=-P:N=P):N=0,g[1].push(N),2*y===O+1&&(y=1-y),2*S===N+1&&(S=1-S),f.iushrn(1),u.iushrn(1)}return g}t.getJSF=n;function s(f,u,g){var y="_"+u;f.prototype[u]=function(){return this[y]!==void 0?this[y]:this[y]=g.call(this)}}t.cachedProperty=s;function o(f){return typeof f=="string"?t.toArray(f,"hex"):f}t.parseBytes=o;function a(f){return new Le.default(f,"hex","le")}t.intFromLE=a}),hf=Jt.getNAF,k_=Jt.getJSF,df=Jt.assert;function Xi(r,e){this.type=r,this.p=new Le.default(e.p,16),this.red=e.prime?Le.default.red(e.prime):Le.default.mont(this.p),this.zero=new Le.default(0).toRed(this.red),this.one=new Le.default(1).toRed(this.red),this.two=new Le.default(2).toRed(this.red),this.n=e.n&&new Le.default(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 t=this.n&&this.p.div(this.n);!t||t.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var Gn=Xi;Xi.prototype.point=function(){throw new Error("Not implemented")};Xi.prototype.validate=function(){throw new Error("Not implemented")};Xi.prototype._fixedNafMul=function(e,t){df(e.precomputed);var i=e._getDoubles(),n=hf(t,1,this._bitLength),s=(1<=a;u--)f=(f<<1)+n[u];o.push(f)}for(var g=this.jpoint(null,null,null),y=this.jpoint(null,null,null),S=s;S>0;S--){for(a=0;a=0;f--){for(var u=0;f>=0&&o[f]===0;f--)u++;if(f>=0&&u++,a=a.dblp(u),f<0)break;var g=o[f];df(g!==0),e.type==="affine"?g>0?a=a.mixedAdd(s[g-1>>1]):a=a.mixedAdd(s[-g-1>>1].neg()):g>0?a=a.add(s[g-1>>1]):a=a.add(s[-g-1>>1].neg())}return e.type==="affine"?a.toP():a};Xi.prototype._wnafMulAdd=function(e,t,i,n,s){var o=this._wnafT1,a=this._wnafT2,f=this._wnafT3,u=0,g,y,S;for(g=0;g=1;g-=2){var A=g-1,P=g;if(o[A]!==1||o[P]!==1){f[A]=hf(i[A],o[A],this._bitLength),f[P]=hf(i[P],o[P],this._bitLength),u=Math.max(f[A].length,u),u=Math.max(f[P].length,u);continue}var O=[t[A],null,null,t[P]];t[A].y.cmp(t[P].y)===0?(O[1]=t[A].add(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg())):t[A].y.cmp(t[P].y.redNeg())===0?(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].add(t[P].neg())):(O[1]=t[A].toJ().mixedAdd(t[P]),O[2]=t[A].toJ().mixedAdd(t[P].neg()));var N=[-3,-1,-5,-7,0,7,5,1,3],U=k_(i[A],i[P]);for(u=Math.max(U[0].length,u),f[A]=new Array(u),f[P]=new Array(u),y=0;y=0;g--){for(var L=0;g>=0;){var C=!0;for(y=0;y=0&&L++,j=j.dblp(L),g<0)break;for(y=0;y0?S=a[y][W-1>>1]:W<0&&(S=a[y][-W-1>>1].neg()),S.type==="affine"?j=j.mixedAdd(S):j=j.add(S))}}for(g=0;g=Math.ceil((e.bitLength()+1)/t.step):!1};ur.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],n=this,s=0;s=0&&(I=u,A=g),y.negative&&(y=y.neg(),S=S.neg()),I.negative&&(I=I.neg(),A=A.neg()),[{a:y,b:S},{a:I,b:A}]};hr.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],n=t[1],s=n.b.mul(e).divRound(this.n),o=i.b.neg().mul(e).divRound(this.n),a=s.mul(i.a),f=o.mul(n.a),u=s.mul(i.b),g=o.mul(n.b),y=e.sub(a).sub(f),S=u.add(g).neg();return{k1:y,k2:S}};hr.prototype.pointFromX=function(e,t){e=new Le.default(e,16),e.red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=i.redSqrt();if(n.redSqr().redSub(i).cmp(this.zero)!==0)throw new Error("invalid point");var s=n.fromRed().isOdd();return(t&&!s||!t&&s)&&(n=n.redNeg()),this.point(e,n)};hr.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,n=this.a.redMul(t),s=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return i.redSqr().redISub(s).cmpn(0)===0};hr.prototype._endoWnafMulAdd=function(e,t,i){for(var n=this._endoWnafT1,s=this._endoWnafT2,o=0;o":""};pt.prototype.isInfinity=function(){return this.inf};pt.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 t=this.y.redSub(e.y);t.cmpn(0)!==0&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,n)};pt.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 t=this.curve.a,i=this.x.redSqr(),n=e.redInvm(),s=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(n),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)};pt.prototype.getX=function(){return this.x.fromRed()};pt.prototype.getY=function(){return this.y.fromRed()};pt.prototype.mul=function(e){return e=new Le.default(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)};pt.prototype.mulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s):this.curve._wnafMulAdd(1,n,s,2)};pt.prototype.jmulAdd=function(e,t,i){var n=[this,t],s=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(n,s,!0):this.curve._wnafMulAdd(1,n,s,2,!0)};pt.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)};pt.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,n=function(s){return s.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(n)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(n)}}}return t};pt.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 _t(r,e,t,i){Gn.BasePoint.call(this,r,"jacobian"),e===null&&t===null&&i===null?(this.x=this.curve.one,this.y=this.curve.one,this.z=new Le.default(0)):(this.x=new Le.default(e,16),this.y=new Le.default(t,16),this.z=new Le.default(i,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}Td(_t,Gn.BasePoint);hr.prototype.jpoint=function(e,t,i){return new _t(this,e,t,i)};_t.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(i,n)};_t.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)};_t.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),n=this.x.redMul(t),s=e.x.redMul(i),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(i.redMul(this.z)),f=n.redSub(s),u=o.redSub(a);if(f.cmpn(0)===0)return u.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var g=f.redSqr(),y=g.redMul(f),S=n.redMul(g),I=u.redSqr().redIAdd(y).redISub(S).redISub(S),A=u.redMul(S.redISub(I)).redISub(o.redMul(y)),P=this.z.redMul(e.z).redMul(f);return this.curve.jpoint(I,A,P)};_t.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,n=e.x.redMul(t),s=this.y,o=e.y.redMul(t).redMul(this.z),a=i.redSub(n),f=s.redSub(o);if(a.cmpn(0)===0)return f.cmpn(0)!==0?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),g=u.redMul(a),y=i.redMul(u),S=f.redSqr().redIAdd(g).redISub(y).redISub(y),I=f.redMul(y.redISub(S)).redISub(s.redMul(g)),A=this.z.redMul(a);return this.curve.jpoint(S,I,A)};_t.prototype.dblp=function(e){if(e===0)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t=0)return!1;if(i.redIAdd(s),this.x.cmp(i)===0)return!0}};_t.prototype.inspect=function(){return this.isInfinity()?"":""};_t.prototype.isInfinity=function(){return this.z.cmpn(0)===0};var ff=$s(function(r,e){"use strict";var t=e;t.base=Gn,t.short=j_,t.mont=null,t.edwards=null}),uf=$s(function(r,e){"use strict";var t=e,i=Jt.assert;function n(a){a.type==="short"?this.curve=new ff.short(a):a.type==="edwards"?this.curve=new ff.edwards(a):this.curve=new ff.mont(a),this.g=this.curve.g,this.n=this.curve.n,this.hash=a.hash,i(this.g.validate(),"Invalid curve"),i(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}t.PresetCurve=n;function s(a,f){Object.defineProperty(t,a,{configurable:!0,enumerable:!0,get:function(){var u=new n(f);return Object.defineProperty(t,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:ai.default.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:ai.default.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:ai.default.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:ai.default.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:ai.default.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:ai.default.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:ai.default.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:ai.default.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",o]})});function Yi(r){if(!(this instanceof Yi))return new Yi(r);this.hash=r.hash,this.predResist=!!r.predResist,this.outLen=this.hash.outSize,this.minEntropy=r.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var e=Tr.toArray(r.entropy,r.entropyEnc||"hex"),t=Tr.toArray(r.nonce,r.nonceEnc||"hex"),i=Tr.toArray(r.pers,r.persEnc||"hex");Md(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(e,t,i)}var fb=Yi;Yi.prototype._init=function(e,t,i){var n=e.concat(t).concat(i);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(i||[])),this._reseed=1};Yi.prototype.generate=function(e,t,i,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");typeof t!="string"&&(n=i,i=t,t=null),i&&(i=Tr.toArray(i,n||"hex"),this._update(i));for(var s=[];s.length"};var K_=Jt.assert;function lf(r,e){if(r instanceof lf)return r;this._importDER(r,e)||(K_(r.r&&r.s,"Signature without r or s"),this.r=new Le.default(r.r,16),this.s=new Le.default(r.s,16),r.recoveryParam===void 0?this.recoveryParam=null:this.recoveryParam=r.recoveryParam)}var pf=lf;function V_(){this.place=0}function Sd(r,e){var t=r[e.place++];if(!(t&128))return t;var i=t&15;if(i===0||i>4)return!1;for(var n=0,s=0,o=e.place;s>>=0;return n<=127?!1:(e.place=o,n)}function ab(r){for(var e=0,t=r.length-1;!r[e]&&!(r[e+1]&128)&&e>>3);for(r.push(t|128);--t;)r.push(e>>>(t<<3)&255);r.push(e)}lf.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(t[0]&128&&(t=[0].concat(t)),i[0]&128&&(i=[0].concat(i)),t=ab(t),i=ab(i);!i[0]&&!(i[1]&128);)i=i.slice(1);var n=[2];Id(n,t.length),n=n.concat(t),n.push(2),Id(n,i.length);var s=n.concat(i),o=[48];return Id(o,s.length),o=o.concat(s),Jt.encode(o,e)};var $_=function(){throw new Error("unsupported")},ub=Jt.assert;function fr(r){if(!(this instanceof fr))return new fr(r);typeof r=="string"&&(ub(Object.prototype.hasOwnProperty.call(uf,r),"Unknown curve "+r),r=uf[r]),r instanceof uf.PresetCurve&&(r={curve:r}),this.curve=r.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=r.curve.g,this.g.precompute(r.curve.n.bitLength()+1),this.hash=r.hash||r.curve.hash}var H_=fr;fr.prototype.keyPair=function(e){return new Pd(this,e)};fr.prototype.keyFromPrivate=function(e,t){return Pd.fromPrivate(this,e,t)};fr.prototype.keyFromPublic=function(e,t){return Pd.fromPublic(this,e,t)};fr.prototype.genKeyPair=function(e){e||(e={});for(var t=new fb({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||$_(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new Le.default(2));;){var s=new Le.default(t.generate(i));if(!(s.cmp(n)>0))return s.iaddn(1),this.keyFromPrivate(s)}};fr.prototype._truncateToN=function(e,t){var i=e.byteLength()*8-this.n.bitLength();return i>0&&(e=e.ushrn(i)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e};fr.prototype.sign=function(e,t,i,n){typeof i=="object"&&(n=i,i=null),n||(n={}),t=this.keyFromPrivate(t,i),e=this._truncateToN(new Le.default(e,16));for(var s=this.n.byteLength(),o=t.getPrivate().toArray("be",s),a=e.toArray("be",s),f=new fb({hash:this.hash,entropy:o,nonce:a,pers:n.pers,persEnc:n.persEnc||"utf8"}),u=this.n.sub(new Le.default(1)),g=0;;g++){var y=n.k?n.k(g):new Le.default(f.generate(this.n.byteLength()));if(y=this._truncateToN(y,!0),!(y.cmpn(1)<=0||y.cmp(u)>=0)){var S=this.g.mul(y);if(!S.isInfinity()){var I=S.getX(),A=I.umod(this.n);if(A.cmpn(0)!==0){var P=y.invm(this.n).mul(A.mul(t.getPrivate()).iadd(e));if(P=P.umod(this.n),P.cmpn(0)!==0){var O=(S.getY().isOdd()?1:0)|(I.cmp(A)!==0?2:0);return n.canonical&&P.cmp(this.nh)>0&&(P=this.n.sub(P),O^=1),new pf({r:A,s:P,recoveryParam:O})}}}}}};fr.prototype.verify=function(e,t,i,n){e=this._truncateToN(new Le.default(e,16)),i=this.keyFromPublic(i,n),t=new pf(t,"hex");var s=t.r,o=t.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),f=a.mul(e).umod(this.n),u=a.mul(s).umod(this.n),g;return this.curve._maxwellTrick?(g=this.g.jmulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.eqXToP(s)):(g=this.g.mulAdd(f,i.getPublic(),u),g.isInfinity()?!1:g.getX().umod(this.n).cmp(s)===0)};fr.prototype.recoverPubKey=function(r,e,t,i){ub((3&t)===t,"The recovery param is more than two bits"),e=new pf(e,i);var n=this.n,s=new Le.default(r),o=e.r,a=e.s,f=t&1,u=t>>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),f):o=this.curve.pointFromX(o,f);var g=e.r.invm(n),y=n.sub(s).mul(g).umod(n),S=a.mul(g).umod(n);return this.g.mulAdd(y,o,S)};fr.prototype.getKeyRecoveryParam=function(r,e,t,i){if(e=new pf(e,i),e.recoveryParam!==null)return e.recoveryParam;for(var n=0;n<4;n++){var s;try{s=this.recoverPubKey(r,e,n)}catch{continue}if(s.eq(t))return n}throw new Error("Unable to find valid recovery factor")};var G_=$s(function(r,e){"use strict";var t=e;t.version="6.5.4",t.utils=Jt,t.rand=function(){throw new Error("unsupported")},t.curve=ff,t.curves=uf,t.ec=H_,t.eddsa=null}),hb=G_.ec;var db="signing-key/5.7.0";var Nd=new lt(db),Rd=null;function ci(){return Rd||(Rd=new hb("secp256k1")),Rd}var Dd=class{constructor(e){qs(this,"curve","secp256k1"),qs(this,"privateKey",Pt(e)),rf(this.privateKey)!==32&&Nd.throwArgumentError("invalid private key","privateKey","[[ REDACTED ]]");let t=ci().keyFromPrivate(Qe(this.privateKey));qs(this,"publicKey","0x"+t.getPublic(!1,"hex")),qs(this,"compressedPublicKey","0x"+t.getPublic(!0,"hex")),qs(this,"_isSigningKey",!0)}_addPoint(e){let t=ci().keyFromPublic(Qe(this.publicKey)),i=ci().keyFromPublic(Qe(e));return"0x"+t.pub.add(i.pub).encodeCompressed("hex")}signDigest(e){let t=ci().keyFromPrivate(Qe(this.privateKey)),i=Qe(e);i.length!==32&&Nd.throwArgumentError("bad digest length","digest",e);let n=t.sign(i,{canonical:!0});return sf({recoveryParam:n.recoveryParam,r:Gi("0x"+n.r.toString(16),32),s:Gi("0x"+n.s.toString(16),32)})}computeSharedSecret(e){let t=ci().keyFromPrivate(Qe(this.privateKey)),i=ci().keyFromPublic(Qe(Cd(e)));return Gi("0x"+t.derive(i.getPublic()).toString(16),32)}static isSigningKey(e){return!!(e&&e._isSigningKey)}};function lb(r,e){let t=sf(e),i={r:Qe(t.r),s:Qe(t.s)};return"0x"+ci().recoverPubKey(Qe(r),i,t.recoveryParam).encode("hex",!1)}function Cd(r,e){let t=Qe(r);if(t.length===32){let i=new Dd(t);return e?"0x"+ci().keyFromPrivate(t).getPublic(!0,"hex"):i.publicKey}else{if(t.length===33)return e?Pt(t):"0x"+ci().keyFromPublic(t).getPublic(!1,"hex");if(t.length===65)return e?"0x"+ci().keyFromPublic(t).getPublic(!0,"hex"):Pt(t)}return Nd.throwArgumentError("invalid public or private key","key","[REDACTED]")}var pb="transactions/5.7.0";var HD=new lt(pb),gb;(function(r){r[r.legacy=0]="legacy",r[r.eip2930=1]="eip2930",r[r.eip1559=2]="eip1559"})(gb||(gb={}));function W_(r){let e=Cd(r);return Sm(nf(Us(nf(e,1)),12))}function mb(r,e){return W_(lb(Qe(r),e))}var nl=Be(Sb()),Kv=Be(Rb()),va=Be($o()),Zs=Be(Db()),Uf=Be(Fb());var Vv=Be(Pv());var Rv={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var XE=":";function ya(r){let[e,t]=r.split(XE);return{namespace:e,reference:t}}function $v(r,e){return r.includes(":")?[r]:e.chains||[]}var QE=Object.defineProperty,Nv=Object.getOwnPropertySymbols,ZE=Object.prototype.hasOwnProperty,e9=Object.prototype.propertyIsEnumerable,Dv=(r,e,t)=>e in r?QE(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Cv=(r,e)=>{for(var t in e||(e={}))ZE.call(e,t)&&Dv(r,t,e[t]);if(Nv)for(var t of Nv(e))e9.call(e,t)&&Dv(r,t,e[t]);return r},t9="ReactNative",Vt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};var r9="js";function wa(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function ts(){return!(0,Li.getDocument)()&&!!(0,Li.getNavigator)()&&navigator.product===t9}function eo(){return!wa()&&!!(0,Li.getNavigator)()&&!!(0,Li.getDocument)()}function xa(){return ts()?Vt.reactNative:wa()?Vt.node:eo()?Vt.browser:Vt.unknown}function Hv(){var r;try{return ts()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(r=global.Application)==null?void 0:r.applicationId:void 0}catch{return}}function i9(r,e){let t=Qs.parse(r);return t=Cv(Cv({},t),e),r=Qs.stringify(t),r}function to(){return(0,jv.getWindowMetadata)()||{name:"",description:"",url:"",icons:[""]}}function n9(){if(xa()===Vt.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){let{OS:t,Version:i}=global.Platform;return[t,i].join("-")}let r=O1();if(r===null)return"unknown";let e=r.os?r.os.replace(" ","").toLowerCase():"unknown";return r.type==="browser"?[e,r.name,r.version].join("-"):[e,r.version].join("-")}function s9(){var r;let e=xa();return e===Vt.browser?[e,((r=(0,Li.getLocation)())==null?void 0:r.host)||"unknown"].join(":"):e}function sl(r,e,t){let i=n9(),n=s9();return[[r,e].join("-"),[r9,t].join("-"),i,n].join("/")}function Gv({protocol:r,version:e,relayUrl:t,sdkVersion:i,auth:n,projectId:s,useOnCloseEvent:o,bundleId:a}){let f=t.split("?"),u=sl(r,e,i),g={auth:n,ua:u,projectId:s,useOnCloseEvent:o||void 0,origin:a||void 0},y=i9(f[1]||"",g);return f[0]+"?"+y}function Zn(r,e){return r.filter(t=>e.includes(t)).length===r.length}function ol(r){return Object.fromEntries(r.entries())}function al(r){return new Map(Object.entries(r))}function Fi(r=Oi.FIVE_MINUTES,e){let t=(0,Oi.toMiliseconds)(r||Oi.FIVE_MINUTES),i,n,s;return{resolve:o=>{s&&i&&(clearTimeout(s),i(o))},reject:o=>{s&&n&&(clearTimeout(s),n(o))},done:()=>new Promise((o,a)=>{s=setTimeout(()=>{a(new Error(e))},t),i=o,n=a})}}function rs(r,e,t){return new Promise(async(i,n)=>{let s=setTimeout(()=>n(new Error(t)),e);try{let o=await r;i(o)}catch(o){n(o)}clearTimeout(s)})}function Wv(r,e){if(typeof e=="string"&&e.startsWith(`${r}:`))return e;if(r.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(r.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${r}`)}function Jv(r){return Wv("topic",r)}function Yv(r){return Wv("id",r)}function qf(r){let[e,t]=r.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ut(r,e){return(0,Oi.fromMiliseconds)((e||Date.now())+(0,Oi.toMiliseconds)(r))}function li(r){return Date.now()>=(0,Oi.toMiliseconds)(r)}function Fe(r,e){return`${r}${e?`:${e}`:""}`}function o9(r=[],e=[]){return[...new Set([...r,...e])]}async function Xv({id:r,topic:e,wcDeepLink:t}){var i;try{if(!t)return;let n=typeof t=="string"?JSON.parse(t):t,s=n?.href;if(typeof s!="string")return;let o=a9(s,r,e),a=xa();if(a===Vt.browser){if(!((i=(0,Li.getDocument)())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}o.startsWith("https://")||o.startsWith("http://")?window.open(o,"_blank","noreferrer noopener"):window.open(o,c9()?"_blank":"_self","noreferrer noopener")}else a===Vt.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(n){console.error(n)}}function a9(r,e,t){let i=`requestId=${e}&sessionTopic=${t}`;r.endsWith("/")&&(r=r.slice(0,-1));let n=`${r}`;if(r.startsWith("https://t.me")){let s=r.includes("?")?"&startapp=":"?startapp=";n=`${n}${s}${f9(i,!0)}`}else n=`${n}/wc?${i}`;return n}async function Qv(r,e){let t="";try{if(eo()&&(t=localStorage.getItem(e),t))return t;t=await r.getItem(e)}catch(i){console.error(i)}return t}function cl(r,e){if(!r.includes(e))return null;let t=r.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function fl(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,r=>{let e=Math.random()*16|0;return(r==="x"?e:e&3|8).toString(16)})}function _a(){return typeof process<"u"&&process.env.IS_VITEST==="true"}function c9(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function f9(r,e=!1){let t=Buffer.from(r).toString("base64");return e?t.replace(/[=]/g,""):t}function Zv(r){return Buffer.from(r,"base64").toString("utf-8")}var u9="https://rpc.walletconnect.org/v1";async function h9(r,e,t,i,n,s){switch(t.t){case"eip191":return d9(r,e,t.s);case"eip1271":return await l9(r,e,t.s,i,n,s);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}function d9(r,e,t){return mb(of(e),t).toLowerCase()===r.toLowerCase()}async function l9(r,e,t,i,n,s){let o=ya(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{let a="0x1626ba7e",f="0000000000000000000000000000000000000000000000000000000000000040",u="0000000000000000000000000000000000000000000000000000000000000041",g=t.substring(2),y=of(e).substring(2),S=a+y+f+u+g,I=await fetch(`${s||u9}/?chainId=${i}&projectId=${n}`,{method:"POST",body:JSON.stringify({id:p9(),jsonrpc:"2.0",method:"eth_call",params:[{to:r,data:S},"latest"]})}),{result:A}=await I.json();return A?A.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function p9(){return Date.now()+Math.floor(Math.random()*1e3)}var g9=Object.defineProperty,m9=Object.defineProperties,b9=Object.getOwnPropertyDescriptors,Ov=Object.getOwnPropertySymbols,v9=Object.prototype.hasOwnProperty,y9=Object.prototype.propertyIsEnumerable,Lv=(r,e,t)=>e in r?g9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,w9=(r,e)=>{for(var t in e||(e={}))v9.call(e,t)&&Lv(r,t,e[t]);if(Ov)for(var t of Ov(e))y9.call(e,t)&&Lv(r,t,e[t]);return r},x9=(r,e)=>m9(r,b9(e)),_9="did:pkh:",ul=r=>r?.split(":"),E9=r=>{let e=r&&ul(r);if(e)return r.includes(_9)?e[3]:e[1]},Bf=r=>{let e=r&&ul(r);if(e)return e[2]+":"+e[3]},Ea=r=>{let e=r&&ul(r);if(e)return e.pop()};async function hl(r){let{cacao:e,projectId:t}=r,{s:i,p:n}=e,s=dl(n,n.iss),o=Ea(n.iss);return await h9(o,s,i,Bf(n.iss),t)}var dl=(r,e)=>{let t=`${r.domain} wants you to sign in with your Ethereum account:`,i=Ea(e);if(!r.aud&&!r.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let n=r.statement||void 0,s=`URI: ${r.aud||r.uri}`,o=`Version: ${r.version}`,a=`Chain ID: ${E9(e)}`,f=`Nonce: ${r.nonce}`,u=`Issued At: ${r.iat}`,g=r.exp?`Expiration Time: ${r.exp}`:void 0,y=r.nbf?`Not Before: ${r.nbf}`:void 0,S=r.requestId?`Request ID: ${r.requestId}`:void 0,I=r.resources?`Resources:${r.resources.map(P=>` -- ${P}`).join("")}`:void 0,A=Sa(r.resources);if(A){let P=ba(A);n=R9(n,P)}return[t,i,"",n,"",s,o,a,f,u,g,y,S,I].filter(P=>P!=null).join(` -`)};function S9(r){return Buffer.from(JSON.stringify(r)).toString("base64")}function I9(r){return JSON.parse(Buffer.from(r,"base64").toString("utf-8"))}function es(r){if(!r)throw new Error("No recap provided, value is undefined");if(!r.att)throw new Error("No `att` property found");let e=Object.keys(r.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{let i=r.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(n=>{let s=i[n];if(!Array.isArray(s))throw new Error(`Ability limits ${n} must be an array of objects, found: ${s}`);if(!s.length)throw new Error(`Value of ${n} is empty array, must be an array with objects`);s.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${n}) must be an array of objects, found: ${o}`)})})})}function A9(r,e,t,i={}){return t?.sort((n,s)=>n.localeCompare(s)),{att:{[r]:M9(e,t,i)}}}function M9(r,e,t={}){e=e?.sort((n,s)=>n.localeCompare(s));let i=e.map(n=>({[`${r}/${n}`]:[t]}));return Object.assign({},...i)}function ey(r){return es(r),`urn:recap:${S9(r).replace(/=/g,"")}`}function ba(r){let e=I9(r.replace("urn:recap:",""));return es(e),e}function ty(r,e,t){let i=A9(r,e,t);return ey(i)}function T9(r){return r&&r.includes("urn:recap:")}function ry(r,e){let t=ba(r),i=ba(e),n=P9(t,i);return ey(n)}function P9(r,e){es(r),es(e);let t=Object.keys(r.att).concat(Object.keys(e.att)).sort((n,s)=>n.localeCompare(s)),i={att:{}};return t.forEach(n=>{var s,o;Object.keys(((s=r.att)==null?void 0:s[n])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[n])||{})).sort((a,f)=>a.localeCompare(f)).forEach(a=>{var f,u;i.att[n]=x9(w9({},i.att[n]),{[a]:((f=r.att[n])==null?void 0:f[a])||((u=e.att[n])==null?void 0:u[a])})})}),i}function R9(r="",e){es(e);let t="I further authorize the stated URI to perform the following actions on my behalf: ";if(r.includes(t))return r;let i=[],n=0;Object.keys(e.att).forEach(a=>{let f=Object.keys(e.att[a]).map(y=>({ability:y.split("/")[0],action:y.split("/")[1]}));f.sort((y,S)=>y.action.localeCompare(S.action));let u={};f.forEach(y=>{u[y.ability]||(u[y.ability]=[]),u[y.ability].push(y.action)});let g=Object.keys(u).map(y=>(n++,`(${n}) '${y}': '${u[y].join("', '")}' for '${a}'.`));i.push(g.join(", ").replace(".,","."))});let s=i.join(" "),o=`${t}${s}`;return`${r?r+" ":""}${o}`}function ll(r){var e;let t=ba(r);es(t);let i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(n=>n.split("/")[1]):[]}function pl(r){let e=ba(r);es(e);let t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(n=>{var s;(s=n?.[0])!=null&&s.chains&&t.push(n[0].chains)})}),[...new Set(t.flat())]}function Sa(r){if(!r)return;let e=r?.[r.length-1];return T9(e)?e:void 0}var iy="base10",Ct="base16",pi="base64pad",ro="base64url",Ia="utf8",ny=0,Rr=1,io=2,N9=0,Fv=1,ma=12,gl=32;function sy(){let r=Uf.generateKeyPair();return{privateKey:rt(r.secretKey,Ct),publicKey:rt(r.publicKey,Ct)}}function kf(){let r=(0,va.randomBytes)(gl);return rt(r,Ct)}function oy(r,e){let t=Uf.sharedKey(at(r,Ct),at(e,Ct),!0),i=new Kv.HKDF(Zs.SHA256,t).expand(gl);return rt(i,Ct)}function no(r){let e=(0,Zs.hash)(at(r,Ct));return rt(e,Ct)}function Nr(r){let e=(0,Zs.hash)(at(r,Ia));return rt(e,Ct)}function ay(r){return at(`${r}`,iy)}function sn(r){return Number(rt(r,iy))}function cy(r){let e=ay(typeof r.type<"u"?r.type:ny);if(sn(e)===Rr&&typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");let t=typeof r.senderPublicKey<"u"?at(r.senderPublicKey,Ct):void 0,i=typeof r.iv<"u"?at(r.iv,Ct):(0,va.randomBytes)(ma),n=new nl.ChaCha20Poly1305(at(r.symKey,Ct)).seal(i,at(r.message,Ia));return dy({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:r.encoding})}function fy(r,e){let t=ay(io),i=(0,va.randomBytes)(ma),n=at(r,Ia);return dy({type:t,sealed:n,iv:i,encoding:e})}function uy(r){let e=new nl.ChaCha20Poly1305(at(r.symKey,Ct)),{sealed:t,iv:i}=so({encoded:r.encoded,encoding:r?.encoding}),n=e.open(i,t);if(n===null)throw new Error("Failed to decrypt");return rt(n,Ia)}function hy(r,e){let{sealed:t}=so({encoded:r,encoding:e});return rt(t,Ia)}function dy(r){let{encoding:e=pi}=r;if(sn(r.type)===io)return rt(jn([r.type,r.sealed]),e);if(sn(r.type)===Rr){if(typeof r.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return rt(jn([r.type,r.senderPublicKey,r.iv,r.sealed]),e)}return rt(jn([r.type,r.iv,r.sealed]),e)}function so(r){let{encoded:e,encoding:t=pi}=r,i=at(e,t),n=i.slice(N9,Fv),s=Fv;if(sn(n)===Rr){let u=s+gl,g=u+ma,y=i.slice(s,u),S=i.slice(u,g),I=i.slice(g);return{type:n,sealed:I,iv:S,senderPublicKey:y}}if(sn(n)===io){let u=i.slice(s),g=(0,va.randomBytes)(ma);return{type:n,sealed:u,iv:g}}let o=s+ma,a=i.slice(s,o),f=i.slice(o);return{type:n,sealed:f,iv:a}}function ly(r,e){let t=so({encoded:r,encoding:e?.encoding});return ml({type:sn(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?rt(t.senderPublicKey,Ct):void 0,receiverPublicKey:e?.receiverPublicKey})}function ml(r){let e=r?.type||ny;if(e===Rr){if(typeof r?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof r?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:r?.senderPublicKey,receiverPublicKey:r?.receiverPublicKey}}function bl(r){return r.type===Rr&&typeof r.senderPublicKey=="string"&&typeof r.receiverPublicKey=="string"}function vl(r){return r.type===io}function D9(r){return new Vv.ec("p256").keyFromPublic({x:Buffer.from(r.x,"base64").toString("hex"),y:Buffer.from(r.y,"base64").toString("hex")},"hex")}function C9(r){let e=r.replace(/-/g,"+").replace(/_/g,"/"),t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function O9(r){return Buffer.from(C9(r),"base64")}function py(r,e){let[t,i,n]=r.split("."),s=O9(n);if(s.length!==64)throw new Error("Invalid signature length");let o=s.slice(0,32).toString("hex"),a=s.slice(32,64).toString("hex"),f=`${t}.${i}`,u=new Zs.SHA256().update(Buffer.from(f)).digest(),g=D9(e),y=Buffer.from(u).toString("hex");if(!g.verify(y,{r:o,s:a}))throw new Error("Invalid signature");return Os(r).payload}var L9="irn";function zf(r){return r?.relay||{protocol:L9}}function oo(r){let e=Rv[r];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${r}`);return e}var F9=Object.defineProperty,U9=Object.defineProperties,q9=Object.getOwnPropertyDescriptors,Uv=Object.getOwnPropertySymbols,B9=Object.prototype.hasOwnProperty,k9=Object.prototype.propertyIsEnumerable,qv=(r,e,t)=>e in r?F9(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Bv=(r,e)=>{for(var t in e||(e={}))B9.call(e,t)&&qv(r,t,e[t]);if(Uv)for(var t of Uv(e))k9.call(e,t)&&qv(r,t,e[t]);return r},z9=(r,e)=>U9(r,q9(e));function j9(r,e="-"){let t={},i="relay"+e;return Object.keys(r).forEach(n=>{if(n.startsWith(i)){let s=n.replace(i,""),o=r[n];t[s]=o}}),t}function yl(r){if(!r.includes("wc:")){let f=Zv(r);f!=null&&f.includes("wc:")&&(r=f)}r=r.includes("wc://")?r.replace("wc://",""):r,r=r.includes("wc:")?r.replace("wc:",""):r;let e=r.indexOf(":"),t=r.indexOf("?")!==-1?r.indexOf("?"):void 0,i=r.substring(0,e),n=r.substring(e+1,t).split("@"),s=typeof t<"u"?r.substring(t):"",o=Qs.parse(s),a=typeof o.methods=="string"?o.methods.split(","):void 0;return{protocol:i,topic:K9(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:j9(o),methods:a,expiryTimestamp:o.expiryTimestamp?parseInt(o.expiryTimestamp,10):void 0}}function K9(r){return r.startsWith("//")?r.substring(2):r}function V9(r,e="-"){let t="relay",i={};return Object.keys(r).forEach(n=>{let s=t+e+n;r[n]&&(i[s]=r[n])}),i}function wl(r){return`${r.protocol}:${r.topic}@${r.version}?`+Qs.stringify(Bv(z9(Bv({symKey:r.symKey},V9(r.relay)),{expiryTimestamp:r.expiryTimestamp}),r.methods?{methods:r.methods.join(",")}:{}))}function Aa(r,e,t){return`${r}?wc_ev=${t}&topic=${e}`}function ao(r){let e=[];return r.forEach(t=>{let[i,n]=t.split(":");e.push(`${i}:${n}`)}),e}function $9(r){let e=[];return Object.values(r).forEach(t=>{e.push(...ao(t.accounts))}),e}function H9(r,e){let t=[];return Object.values(r).forEach(i=>{ao(i.accounts).includes(e)&&t.push(...i.methods)}),t}function G9(r,e){let t=[];return Object.values(r).forEach(i=>{ao(i.accounts).includes(e)&&t.push(...i.events)}),t}function W9(r){let e={};return r?.forEach(t=>{let[i,n]=t.split(":");e[i]||(e[i]={accounts:[],chains:[],events:[]}),e[i].accounts.push(t),e[i].chains.push(`${i}:${n}`)}),e}function xl(r,e){e=e.map(i=>i.replace("did:pkh:",""));let t=W9(e);for(let[i,n]of Object.entries(t))n.methods?n.methods=o9(n.methods,r):n.methods=r,n.events=["chainChanged","accountsChanged"];return t}var J9={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Y9={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Q(r,e){let{message:t,code:i}=Y9[r];return{message:e?`${t} ${e}`:t,code:i}}function ke(r,e){let{message:t,code:i}=J9[r];return{message:e?`${t} ${e}`:t,code:i}}function an(r,e){return Array.isArray(r)?typeof e<"u"&&r.length?r.every(e):!0:!1}function Ma(r){return Object.getPrototypeOf(r)===Object.prototype&&Object.keys(r).length}function St(r){return typeof r>"u"}function et(r,e){return e&&St(r)?!0:typeof r=="string"&&!!r.trim().length}function _l(r,e){return e&&St(r)?!0:typeof r=="number"&&!isNaN(r)}function gy(r,e){let{requiredNamespaces:t}=e,i=Object.keys(r.namespaces),n=Object.keys(t),s=!0;return Zn(n,i)?(i.forEach(o=>{let{accounts:a,methods:f,events:u}=r.namespaces[o],g=ao(a),y=t[o];(!Zn($v(o,y),g)||!Zn(y.methods,f)||!Zn(y.events,u))&&(s=!1)}),s):!1}function Ff(r){return et(r,!1)&&r.includes(":")?r.split(":").length===2:!1}function X9(r){if(et(r,!1)&&r.includes(":")){let e=r.split(":");if(e.length===3){let t=e[0]+":"+e[1];return!!e[2]&&Ff(t)}}return!1}function my(r){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(et(r,!1)){if(e(r))return!0;let t=Zv(r);return e(t)}}catch{}return!1}function by(r){var e;return(e=r?.proposer)==null?void 0:e.publicKey}function vy(r){return r?.topic}function yy(r,e){let t=null;return et(r?.publicKey,!1)||(t=Q("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function kv(r){let e=!0;return an(r)?r.length&&(e=r.every(t=>et(t,!1))):e=!1,e}function Q9(r,e,t){let i=null;return an(e)&&e.length?e.forEach(n=>{i||Ff(n)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chain ${n} should be a string and conform to "namespace:chainId" format`))}):Ff(r)||(i=ke("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function Z9(r,e,t){let i=null;return Object.entries(r).forEach(([n,s])=>{if(i)return;let o=Q9(n,$v(n,s),`${e} ${t}`);o&&(i=o)}),i}function e7(r,e){let t=null;return an(r)?r.forEach(i=>{t||X9(i)||(t=ke("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=ke("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function t7(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=e7(i?.accounts,`${e} namespace`);n&&(t=n)}),t}function r7(r,e){let t=null;return kv(r?.methods)?kv(r?.events)||(t=ke("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=ke("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function wy(r,e){let t=null;return Object.values(r).forEach(i=>{if(t)return;let n=r7(i,`${e}, namespace`);n&&(t=n)}),t}function xy(r,e,t){let i=null;if(r&&Ma(r)){let n=wy(r,e);n&&(i=n);let s=Z9(r,e,t);s&&(i=s)}else i=Q("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function jf(r,e){let t=null;if(r&&Ma(r)){let i=wy(r,e);i&&(t=i);let n=t7(r,e);n&&(t=n)}else t=Q("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function El(r){return et(r.protocol,!0)}function _y(r,e){let t=!1;return e&&!r?t=!0:r&&an(r)&&r.length&&r.forEach(i=>{t=El(i)}),t}function Ey(r){return typeof r=="number"}function Ot(r){return typeof r<"u"&&typeof r!==null}function Sy(r){return!(!r||typeof r!="object"||!r.code||!_l(r.code,!1)||!r.message||!et(r.message,!1))}function Iy(r){return!(St(r)||!et(r.method,!1))}function Ay(r){return!(St(r)||St(r.result)&&St(r.error)||!_l(r.id,!1)||!et(r.jsonrpc,!1))}function My(r){return!(St(r)||!et(r.name,!1))}function Sl(r,e){return!(!Ff(e)||!$9(r).includes(e))}function Ty(r,e,t){return et(t,!1)?H9(r,e).includes(t):!1}function Py(r,e,t){return et(t,!1)?G9(r,e).includes(t):!1}function Il(r,e,t){let i=null,n=i7(r),s=n7(e),o=Object.keys(n),a=Object.keys(s),f=zv(Object.keys(r)),u=zv(Object.keys(e)),g=f.filter(y=>!u.includes(y));return g.length&&(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces. - Required: ${g.toString()} - Received: ${Object.keys(e).toString()}`)),Zn(o,a)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces. - Required: ${o.toString()} - Approved: ${a.toString()}`)),Object.keys(e).forEach(y=>{if(!y.includes(":")||i)return;let S=ao(e[y].accounts);S.includes(y)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${y} - Required: ${y} - Approved: ${S.toString()}`))}),o.forEach(y=>{i||(Zn(n[y].methods,s[y].methods)?Zn(n[y].events,s[y].events)||(i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${y}`)):i=Q("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${y}`))}),i}function i7(r){let e={};return Object.keys(r).forEach(t=>{var i;t.includes(":")?e[t]=r[t]:(i=r[t].chains)==null||i.forEach(n=>{e[n]={methods:r[t].methods,events:r[t].events}})}),e}function zv(r){return[...new Set(r.map(e=>e.includes(":")?e.split(":")[0]:e))]}function n7(r){let e={};return Object.keys(r).forEach(t=>{t.includes(":")?e[t]=r[t]:ao(r[t].accounts)?.forEach(n=>{e[n]={accounts:r[t].accounts.filter(s=>s.includes(`${n}:`)),methods:r[t].methods,events:r[t].events}})}),e}function Ry(r,e){return _l(r,!1)&&r<=e.max&&r>=e.min}function Al(){let r=xa();return new Promise(e=>{switch(r){case Vt.browser:e(s7());break;case Vt.reactNative:e(o7());break;case Vt.node:e(a7());break;default:e(!0)}})}function s7(){return eo()&&navigator?.onLine}async function o7(){return ts()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function a7(){return!0}function Ny(r){switch(xa()){case Vt.browser:c7(r);break;case Vt.reactNative:f7(r);break;case Vt.node:break}}function c7(r){!ts()&&eo()&&(window.addEventListener("online",()=>r(!0)),window.addEventListener("offline",()=>r(!1)))}function f7(r){ts()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>r(e?.isConnected))}var il={},on=class{static get(e){return il[e]}static set(e,t){il[e]=t}static delete(e){delete il[e]}};var Gy=Be(Fn());var Ft={};qt(Ft,{DEFAULT_ERROR:()=>Pa,IBaseJsonRpcProvider:()=>Xf,IEvents:()=>Ra,IJsonRpcConnection:()=>Nl,IJsonRpcProvider:()=>Na,INTERNAL_ERROR:()=>Kf,INVALID_PARAMS:()=>Ly,INVALID_REQUEST:()=>Cy,METHOD_NOT_FOUND:()=>Oy,PARSE_ERROR:()=>Dy,RESERVED_ERROR_CODES:()=>Ml,SERVER_ERROR:()=>Ta,SERVER_ERROR_CODE_RANGE:()=>Vf,STANDARD_ERROR_MAP:()=>cn,formatErrorMessage:()=>$y,formatJsonRpcError:()=>is,formatJsonRpcRequest:()=>Cr,formatJsonRpcResult:()=>co,getBigIntRpcId:()=>Dr,getError:()=>Hf,getErrorByCode:()=>Gf,isHttpUrl:()=>w7,isJsonRpcError:()=>Lt,isJsonRpcPayload:()=>Cl,isJsonRpcRequest:()=>fo,isJsonRpcResponse:()=>hn,isJsonRpcResult:()=>Xt,isJsonRpcValidationInvalid:()=>x7,isLocalhostUrl:()=>Dl,isNodeJs:()=>Vy,isReservedErrorCode:()=>$f,isServerErrorCode:()=>u7,isValidDefaultRoute:()=>Jf,isValidErrorCode:()=>Fy,isValidLeadingWildcardRoute:()=>g7,isValidRoute:()=>p7,isValidTrailingWildcardRoute:()=>m7,isValidWildcardRoute:()=>Yf,isWsUrl:()=>Qf,parseConnectionError:()=>Tl,payloadId:()=>gi,validateJsonRpcError:()=>h7});var Dy="PARSE_ERROR",Cy="INVALID_REQUEST",Oy="METHOD_NOT_FOUND",Ly="INVALID_PARAMS",Kf="INTERNAL_ERROR",Ta="SERVER_ERROR",Ml=[-32700,-32600,-32601,-32602,-32603],Vf=[-32e3,-32099],cn={[Dy]:{code:-32700,message:"Parse error"},[Cy]:{code:-32600,message:"Invalid Request"},[Oy]:{code:-32601,message:"Method not found"},[Ly]:{code:-32602,message:"Invalid params"},[Kf]:{code:-32603,message:"Internal error"},[Ta]:{code:-32e3,message:"Server error"}},Pa=Ta;function u7(r){return r<=Vf[0]&&r>=Vf[1]}function $f(r){return Ml.includes(r)}function Fy(r){return typeof r=="number"}function Hf(r){return Object.keys(cn).includes(r)?cn[r]:cn[Pa]}function Gf(r){let e=Object.values(cn).find(t=>t.code===r);return e||cn[Pa]}function h7(r){if(typeof r.error.code>"u")return{valid:!1,error:"Missing code for JSON-RPC error"};if(typeof r.error.message>"u")return{valid:!1,error:"Missing message for JSON-RPC error"};if(!Fy(r.error.code))return{valid:!1,error:`Invalid error code type for JSON-RPC: ${r.error.code}`};if($f(r.error.code)){let e=Gf(r.error.code);if(e.message!==cn[Pa].message&&r.error.message===e.message)return{valid:!1,error:`Invalid error code message for JSON-RPC: ${r.error.code}`}}return{valid:!0}}function Tl(r,e,t){return r.message.includes("getaddrinfo ENOTFOUND")||r.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${t} RPC url at ${e}`):r}var kt={};qt(kt,{isNodeJs:()=>Vy});var Ky=Be(Rl());Ht(kt,Be(Rl()));var Vy=Ky.isNode;Ht(Ft,kt);function gi(r=3){let e=Date.now()*Math.pow(10,r),t=Math.floor(Math.random()*Math.pow(10,r));return e+t}function Dr(r=6){return BigInt(gi(r))}function Cr(r,e,t){return{id:t||gi(),jsonrpc:"2.0",method:r,params:e}}function co(r,e){return{id:r,jsonrpc:"2.0",result:e}}function is(r,e,t){return{id:r,jsonrpc:"2.0",error:$y(e,t)}}function $y(r,e){return typeof r>"u"?Hf(Kf):(typeof r=="string"&&(r=Object.assign(Object.assign({},Hf(Ta)),{message:r})),typeof e<"u"&&(r.data=e),$f(r.code)&&(r=Gf(r.code)),r)}function p7(r){return r.includes("*")?Yf(r):!/\W/g.test(r)}function Jf(r){return r==="*"}function Yf(r){return Jf(r)?!0:!(!r.includes("*")||r.split("*").length!==2||r.split("*").filter(e=>e.trim()==="").length!==1)}function g7(r){return!Jf(r)&&Yf(r)&&!r.split("*")[0].trim()}function m7(r){return!Jf(r)&&Yf(r)&&!r.split("*")[1].trim()}var Ra=class{},Nl=class extends Ra{constructor(e){super()}},Xf=class extends Ra{constructor(){super()}},Na=class extends Xf{constructor(e){super()}};var b7="^https?:",v7="^wss?:";function y7(r){let e=r.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Hy(r,e){let t=y7(r);return typeof t>"u"?!1:new RegExp(e).test(t)}function w7(r){return Hy(r,b7)}function Qf(r){return Hy(r,v7)}function Dl(r){return new RegExp("wss?://localhost(:d{2,5})?").test(r)}function Cl(r){return typeof r=="object"&&"id"in r&&"jsonrpc"in r&&r.jsonrpc==="2.0"}function fo(r){return Cl(r)&&"method"in r}function hn(r){return Cl(r)&&(Xt(r)||Lt(r))}function Xt(r){return"result"in r}function Lt(r){return"error"in r}function x7(r){return"error"in r&&r.valid===!1}var Zf=class extends Na{constructor(e){super(e),this.events=new Gy.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(Cr(e.method,e.params||[],e.id||Dr().toString()),t)}async requestStrict(e,t){return new Promise(async(i,n)=>{if(!this.connection.connected)try{await this.open()}catch(s){n(s)}this.events.on(`${e.id}`,s=>{Lt(s)?n(s.error):i(s.result)});try{await this.connection.send(e,t)}catch(s){n(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),hn(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};var Qy=Be(Fn());var _7=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Jy(),E7=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Yy=r=>r.split("?")[0],Xy=10,S7=_7(),eu=class{constructor(e){if(this.url=e,this.events=new Qy.EventEmitter,this.registering=!1,!Qf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(ar(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!Qf(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,n)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),n(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return n(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let n=new URLSearchParams(e).get("origin"),s=(0,Ft.isReactNative)()?{headers:{origin:n}}:{rejectUnauthorized:!Dl(e)},o=new S7(e,[],s);E7()?o.onerror=a=>{let f=a;i(this.emitError(f.error))}:o.on("error",a=>{i(this.emitError(a))}),o.onopen=()=>{this.onOpen(o),t(o)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t=typeof e.data=="string"?Qr(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),n=i.message||i.toString(),s=is(e,n);this.events.emit("payload",s)}parseError(e,t=this.url){return Tl(e,Yy(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Xy&&this.events.setMaxListeners(Xy)}emitError(e){let t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${Yy(this.url)}`));return this.events.emit("register_error",t),t}};var t2=Be(Cw()),r2=Be(Qc()),i2="wc",n2=2,m0="core",yi=`${i2}@2:${m0}:`,tI={name:m0,logger:"error"},rI={database:":memory:"},iI="crypto",Ow="client_ed25519_seed",nI=ne.ONE_DAY,sI="keychain",oI="0.3",aI="messages",cI="0.3",fI=ne.SIX_HOURS,uI="publisher",b0="irn",hI="error",s2="wss://relay.walletconnect.org",dI="relayer",Ut={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lI="_subscription",gr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},pI=.1;var Gl="2.17.1";var We={link_mode:"link_mode",relay:"relay"},gI="0.3",mI="WALLETCONNECT_CLIENT_ID",Lw="WALLETCONNECT_LINK_MODE_APPS",bi={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var bI="subscription",vI="0.3",yI=ne.FIVE_SECONDS*1e3,wI="pairing",xI="0.3";var Ua={wc_pairingDelete:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ne.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ne.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ne.ONE_DAY,prompt:!1,tag:0},res:{ttl:ne.ONE_DAY,prompt:!1,tag:0}}},pn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Or={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},_I="history",EI="0.3",SI="expirer",Qt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},II="0.3";var AI="verify-api",MI="https://verify.walletconnect.com",o2="https://verify.walletconnect.org",po=o2,TI=`${po}/v3`,PI=[MI,o2],RI="echo",NI="https://echo.walletconnect.com";var Lr={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},vi={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},mr={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},gn={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},mn={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},go={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},DI=.1,CI="event-client",OI=86400,LI="https://pulse.walletconnect.org/batch";function FI(r,e){if(r.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i>>0,B=new Uint8Array(k);N!==U;){for(var j=A[N],V=0,L=k-1;(j!==0||V>>0,B[L]=j%a>>>0,j=j/a>>>0;if(j!==0)throw new Error("Non-zero carry");O=V,N++}for(var C=k-O;C!==k&&B[C]===0;)C++;for(var W=f.repeat(P);C>>0,k=new Uint8Array(U);A[P];){var B=t[A.charCodeAt(P)];if(B===255)return;for(var j=0,V=U-1;(B!==0||j>>0,k[V]=B%256>>>0,B=B/256>>>0;if(B!==0)throw new Error("Non-zero carry");N=j,P++}if(A[P]!==" "){for(var L=U-N;L!==U&&k[L]===0;)L++;for(var C=new Uint8Array(O+(U-L)),W=O;L!==U;)C[W++]=k[L++];return C}}}function I(A){var P=S(A);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:y,decodeUnsafe:S,decode:I}}var UI=FI,qI=UI,a2=r=>{if(r instanceof Uint8Array&&r.constructor.name==="Uint8Array")return r;if(r instanceof ArrayBuffer)return new Uint8Array(r);if(ArrayBuffer.isView(r))return new Uint8Array(r.buffer,r.byteOffset,r.byteLength);throw new Error("Unknown type, must be binary type")},BI=r=>new TextEncoder().encode(r),kI=r=>new TextDecoder().decode(r),Wl=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},Jl=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return c2(this,e)}},Yl=class{constructor(e){this.decoders=e}or(e){return c2(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},c2=(r,e)=>new Yl({...r.decoders||{[r.prefix]:r},...e.decoders||{[e.prefix]:e}}),Xl=class{constructor(e,t,i,n){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=n,this.encoder=new Wl(e,t,i),this.decoder=new Jl(e,t,n)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}},du=({name:r,prefix:e,encode:t,decode:i})=>new Xl(r,e,t,i),ka=({prefix:r,name:e,alphabet:t})=>{let{encode:i,decode:n}=qI(t,e);return du({prefix:r,name:e,encode:i,decode:s=>a2(n(s))})},zI=(r,e,t,i)=>{let n={};for(let g=0;g=8&&(a-=8,o[u++]=255&f>>a)}if(a>=t||255&f<<8-a)throw new SyntaxError("Unexpected end of data");return o},jI=(r,e,t)=>{let i=e[e.length-1]==="=",n=(1<t;)o-=t,s+=e[n&a>>o];if(o&&(s+=e[n&a<du({prefix:e,name:r,encode(n){return jI(n,i,t)},decode(n){return zI(n,i,t,r)}}),KI=du({prefix:"\0",name:"identity",encode:r=>kI(r),decode:r=>BI(r)}),VI=Object.freeze({__proto__:null,identity:KI}),$I=It({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),HI=Object.freeze({__proto__:null,base2:$I}),GI=It({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),WI=Object.freeze({__proto__:null,base8:GI}),JI=ka({prefix:"9",name:"base10",alphabet:"0123456789"}),YI=Object.freeze({__proto__:null,base10:JI}),XI=It({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),QI=It({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ZI=Object.freeze({__proto__:null,base16:XI,base16upper:QI}),eA=It({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tA=It({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),rA=It({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),iA=It({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),nA=It({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sA=It({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),oA=It({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),aA=It({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),cA=It({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),fA=Object.freeze({__proto__:null,base32:eA,base32upper:tA,base32pad:rA,base32padupper:iA,base32hex:nA,base32hexupper:sA,base32hexpad:oA,base32hexpadupper:aA,base32z:cA}),uA=ka({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hA=ka({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),dA=Object.freeze({__proto__:null,base36:uA,base36upper:hA}),lA=ka({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),pA=ka({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),gA=Object.freeze({__proto__:null,base58btc:lA,base58flickr:pA}),mA=It({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),bA=It({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),vA=It({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),yA=It({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),wA=Object.freeze({__proto__:null,base64:mA,base64pad:bA,base64url:vA,base64urlpad:yA}),f2=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),xA=f2.reduce((r,e,t)=>(r[t]=e,r),[]),_A=f2.reduce((r,e,t)=>(r[e.codePointAt(0)]=t,r),[]);function EA(r){return r.reduce((e,t)=>(e+=xA[t],e),"")}function SA(r){let e=[];for(let t of r){let i=_A[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}var IA=du({prefix:"\u{1F680}",name:"base256emoji",encode:EA,decode:SA}),AA=Object.freeze({__proto__:null,base256emoji:IA}),MA=u2,Fw=128,TA=127,PA=~TA,RA=Math.pow(2,31);function u2(r,e,t){e=e||[],t=t||0;for(var i=t;r>=RA;)e[t++]=r&255|Fw,r/=128;for(;r&PA;)e[t++]=r&255|Fw,r>>>=7;return e[t]=r|0,u2.bytes=t-i+1,e}var NA=Ql,DA=128,Uw=127;function Ql(r,i){var t=0,i=i||0,n=0,s=i,o,a=r.length;do{if(s>=a)throw Ql.bytes=0,new RangeError("Could not decode varint");o=r[s++],t+=n<28?(o&Uw)<=DA);return Ql.bytes=s-i,t}var CA=Math.pow(2,7),OA=Math.pow(2,14),LA=Math.pow(2,21),FA=Math.pow(2,28),UA=Math.pow(2,35),qA=Math.pow(2,42),BA=Math.pow(2,49),kA=Math.pow(2,56),zA=Math.pow(2,63),jA=function(r){return r(h2.encode(r,e,t),e),Bw=r=>h2.encodingLength(r),Zl=(r,e)=>{let t=e.byteLength,i=Bw(r),n=i+Bw(t),s=new Uint8Array(n+t);return qw(r,s,0),qw(t,s,i),s.set(e,n),new e0(r,t,e,s)},e0=class{constructor(e,t,i,n){this.code=e,this.size=t,this.digest=i,this.bytes=n}},d2=({name:r,code:e,encode:t})=>new t0(r,e,t),t0=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?Zl(this.code,t):t.then(i=>Zl(this.code,i))}else throw Error("Unknown type, must be binary type")}},l2=r=>async e=>new Uint8Array(await crypto.subtle.digest(r,e)),VA=d2({name:"sha2-256",code:18,encode:l2("SHA-256")}),$A=d2({name:"sha2-512",code:19,encode:l2("SHA-512")}),HA=Object.freeze({__proto__:null,sha256:VA,sha512:$A}),p2=0,GA="identity",g2=a2,WA=r=>Zl(p2,g2(r)),JA={code:p2,name:GA,encode:g2,digest:WA},YA=Object.freeze({__proto__:null,identity:JA});new TextEncoder,new TextDecoder;var kw={...VI,...HI,...WI,...YI,...ZI,...fA,...dA,...gA,...wA,...AA};({...HA,...YA});function XA(r=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(r):new Uint8Array(r)}function m2(r,e,t,i){return{name:r,prefix:e,encoder:{name:r,prefix:e,encode:t},decoder:{decode:i}}}var zw=m2("utf8","u",r=>"u"+new TextDecoder("utf8").decode(r),r=>new TextEncoder().encode(r.substring(1))),$l=m2("ascii","a",r=>{let e="a";for(let t=0;t{r=r.substring(1);let e=XA(r.length);for(let t=0;t{if(!this.initialized){let i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}},this.has=i=>(this.isInitialized(),this.keychain.has(i)),this.set=async(i,n)=>{this.isInitialized(),this.keychain.set(i,n),await this.persist()},this.get=i=>{this.isInitialized();let n=this.keychain.get(i);if(typeof n>"u"){let{message:s}=Q("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(s)}return n},this.del=async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()},this.core=e,this.logger=wt(t,this.name)}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ol(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?al(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},i0=class{constructor(e,t,i){this.core=e,this.logger=t,this.name=iI,this.randomSessionIdentifier=kf(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=n=>(this.isInitialized(),this.keychain.has(n)),this.getClientId=async()=>{this.isInitialized();let n=await this.getClientSeed(),s=rd(n);return Xc(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();let n=sy();return this.setPrivateKey(n.publicKey,n.privateKey)},this.signJWT=async n=>{this.isInitialized();let s=await this.getClientSeed(),o=rd(s),a=this.randomSessionIdentifier;return await P1(a,n,nI,o)},this.generateSharedKey=(n,s,o)=>{this.isInitialized();let a=this.getPrivateKey(n),f=oy(a,s);return this.setSymKey(f,o)},this.setSymKey=async(n,s)=>{this.isInitialized();let o=s||no(n);return await this.keychain.set(o,n),o},this.deleteKeyPair=async n=>{this.isInitialized(),await this.keychain.del(n)},this.deleteSymKey=async n=>{this.isInitialized(),await this.keychain.del(n)},this.encode=async(n,s,o)=>{this.isInitialized();let a=ml(o),f=ar(s);if(vl(a))return fy(f,o?.encoding);if(bl(a)){let S=a.senderPublicKey,I=a.receiverPublicKey;n=await this.generateSharedKey(S,I)}let u=this.getSymKey(n),{type:g,senderPublicKey:y}=a;return cy({type:g,symKey:u,message:f,senderPublicKey:y,encoding:o?.encoding})},this.decode=async(n,s,o)=>{this.isInitialized();let a=ly(s,o);if(vl(a)){let f=hy(s,o?.encoding);return Qr(f)}if(bl(a)){let f=a.receiverPublicKey,u=a.senderPublicKey;n=await this.generateSharedKey(f,u)}try{let f=this.getSymKey(n),u=uy({symKey:f,encoded:s,encoding:o?.encoding});return Qr(u)}catch(f){this.logger.error(`Failed to decode message from topic: '${n}', clientId: '${await this.getClientId()}'`),this.logger.error(f)}},this.getPayloadType=(n,s=pi)=>{let o=so({encoded:n,encoding:s});return sn(o.type)},this.getPayloadSenderPublicKey=(n,s=pi)=>{let o=so({encoded:n,encoding:s});return o.senderPublicKey?rt(o.senderPublicKey,Ct):void 0},this.core=e,this.logger=wt(t,this.name),this.keychain=i||new r0(this.core,this.logger)}get context(){return Mt(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Ow)}catch{e=kf(),await this.keychain.set(Ow,e)}return ZA(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},n0=class extends Pc{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name=aI,this.version=cI,this.initialized=!1,this.storagePrefix=yi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}},this.set=async(i,n)=>{this.isInitialized();let s=Nr(n),o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=n,this.messages.set(i,o),await this.persist()),s},this.get=i=>{this.isInitialized();let n=this.messages.get(i);return typeof n>"u"&&(n={}),n},this.has=(i,n)=>{this.isInitialized();let s=this.get(i),o=Nr(n);return typeof s[o]<"u"},this.del=async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()},this.logger=wt(e,this.name),this.core=t}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ol(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?al(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},s0=class extends Rc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new Bi.EventEmitter,this.name=uI,this.queue=new Map,this.publishTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.failedPublishTimeout=(0,ne.toMiliseconds)(ne.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(i,n,s)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:n,opts:s}});let a=s?.ttl||fI,f=zf(s),u=s?.prompt||!1,g=s?.tag||0,y=s?.id||Dr().toString(),S={topic:i,message:n,opts:{ttl:a,relay:f,prompt:u,tag:g,id:y,attestation:s?.attestation}},I=`Failed to publish payload, please try again. id:${y} tag:${g}`,A=Date.now(),P,O=1;try{for(;P===void 0;){if(Date.now()-A>this.publishTimeout)throw new Error(I);this.logger.trace({id:y,attempts:O},`publisher.publish - attempt ${O}`),P=await await rs(this.rpcPublish(i,n,a,f,u,g,y,s?.attestation).catch(N=>this.logger.warn(N)),this.publishTimeout,I),O++,P||await new Promise(N=>setTimeout(N,this.failedPublishTimeout))}this.relayer.events.emit(Ut.publish,S),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:y,topic:i,message:n,opts:s}})}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(o=s?.internal)!=null&&o.throwOnFailedPublish)throw N;this.queue.set(y,S)}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.relayer=e,this.logger=wt(t,this.name),this.registerEventListeners()}get context(){return Mt(this.logger)}rpcPublish(e,t,i,n,s,o,a,f){var u,g,y,S;let I={method:oo(n.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:s,tag:o,attestation:f},id:a};return St((u=I.params)==null?void 0:u.prompt)&&((g=I.params)==null||delete g.prompt),St((y=I.params)==null?void 0:y.tag)&&((S=I.params)==null||delete S.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:I}),this.relayer.request(I)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{let{topic:t,message:i,opts:n}=e;await this.publish(t,i,n)})}registerEventListeners(){this.relayer.core.heartbeat.on(Un.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ut.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ut.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}},o0=class{constructor(){this.map=new Map,this.set=(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let n=i.filter(s=>s!==t);if(!n.length){this.map.delete(e);return}this.map.set(e,n)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}},eM=Object.defineProperty,tM=Object.defineProperties,rM=Object.getOwnPropertyDescriptors,jw=Object.getOwnPropertySymbols,iM=Object.prototype.hasOwnProperty,nM=Object.prototype.propertyIsEnumerable,Kw=(r,e,t)=>e in r?eM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,qa=(r,e)=>{for(var t in e||(e={}))iM.call(e,t)&&Kw(r,t,e[t]);if(jw)for(var t of jw(e))nM.call(e,t)&&Kw(r,t,e[t]);return r},Hl=(r,e)=>tM(r,rM(e)),a0=class extends Cc{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new o0,this.events=new Bi.EventEmitter,this.name=bI,this.version=vI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=yi,this.subscribeTimeout=(0,ne.toMiliseconds)(ne.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(i,n)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}});try{let s=zf(n),o={topic:i,relay:s,transportType:n?.transportType};this.pending.set(i,o);let a=await this.rpcSubscribe(i,s,n);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:n}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(i,n)=>{await this.restartToComplete(),this.isInitialized(),typeof n?.id<"u"?await this.unsubscribeById(i,n.id,n):await this.unsubscribeByTopic(i,n)},this.isSubscribed=async i=>{if(this.topics.includes(i))return!0;let n=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((s,o)=>{let a=new ne.Watch;a.start(n);let f=setInterval(()=>{!this.pending.has(i)&&this.topics.includes(i)&&(clearInterval(f),a.stop(n),s(!0)),a.elapsed(n)>=yI&&(clearInterval(f),a.stop(n),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=wt(t,this.name),this.clientId=""}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let n=zf(i);await this.rpcUnsubscribe(e,t,n);let s=ke("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(n){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(n),n}}async rpcSubscribe(e,t,i){var n;i?.transportType===We.relay&&await this.restartToComplete();let s={method:oo(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(n=i?.internal)==null?void 0:n.throwOnFailedPublish;try{let a=Nr(e+this.clientId);if(i?.transportType===We.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(u=>this.logger.warn(u))},(0,ne.toMiliseconds)(ne.ONE_SECOND)),a;let f=await rs(this.relayer.request(s).catch(u=>this.logger.warn(u)),this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!f&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return f?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ut.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t=e[0].relay,i={method:oo(t.protocol).batchSubscribe,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{return await await rs(this.relayer.request(i).catch(n=>this.logger.warn(n)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;let t=e[0].relay,i={method:oo(t.protocol).batchFetchMessages,params:{topics:e.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let n;try{n=await await rs(this.relayer.request(i).catch(s=>this.logger.warn(s)),this.subscribeTimeout)}catch{this.relayer.events.emit(Ut.connection_stalled)}return n}rpcUnsubscribe(e,t,i){let n={method:oo(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),this.relayer.request(n)}onSubscribe(e,t){this.setSubscription(e,Hl(qa({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,qa({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,qa({},t)),this.topicMap.set(t.topic,e),this.events.emit(bi.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(bi.deleted,Hl(qa({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(bi.sync)}async reset(){if(this.cached.length){let e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t"u"||!e.length)return;if(this.subscriptions.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;let t=await this.rpcBatchSubscribe(e);an(t)&&this.onBatchSubscribe(t.map((i,n)=>Hl(qa({},e[n]),{id:i})))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(t.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(Un.pulse,async()=>{await this.checkPending()}),this.events.on(bi.created,async e=>{let t=bi.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(bi.deleted,async e=>{let t=bi.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.restartInProgress||(clearInterval(t),e())},this.pollingInterval)})}},sM=Object.defineProperty,Vw=Object.getOwnPropertySymbols,oM=Object.prototype.hasOwnProperty,aM=Object.prototype.propertyIsEnumerable,$w=(r,e,t)=>e in r?sM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Hw=(r,e)=>{for(var t in e||(e={}))oM.call(e,t)&&$w(r,t,e[t]);if(Vw)for(var t of Vw(e))aM.call(e,t)&&$w(r,t,e[t]);return r},c0=class extends Nc{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new Bi.EventEmitter,this.name=dI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0,ne.toMiliseconds)(ne.THIRTY_SECONDS+ne.ONE_SECOND),this.request=async t=>{var i,n;this.logger.debug("Publishing Request Payload");let s=t.id||Dr().toString();await this.toEstablishConnection();try{let o=this.provider.request(t);this.requestsInFlight.set(s,{promise:o,request:t}),this.logger.trace({id:s,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - attempt to publish...");let a=await new Promise(async(f,u)=>{let g=()=>{u(new Error(`relayer.request - publish interrupted, id: ${s}`))};this.provider.on(gr.disconnect,g);let y=await o;this.provider.off(gr.disconnect,g),f(y)});return this.logger.trace({id:s,method:t.method,topic:(n=t.params)==null?void 0:n.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s)}},this.resetPingTimeout=()=>{if(wa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,n;(n=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||n.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t)}},this.onPayloadHandler=t=>{this.onProviderPayload(t),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(Ut.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=t=>{this.logger.error(t),this.events.emit(Ut.error,t),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(gr.payload,this.onPayloadHandler),this.provider.on(gr.connect,this.onConnectHandler),this.provider.on(gr.disconnect,this.onDisconnectHandler),this.provider.on(gr.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?wt(e.logger,this.name):(0,jo.default)(Vo({level:e.logger||hI})),this.messages=new n0(this.logger,e.core),this.subscriber=new a0(this,this.logger),this.publisher=new s0(this,this.logger),this.relayUrl=e?.relayUrl||s2,this.projectId=e.projectId,this.bundleId=Hv(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(e){this.logger.warn(e)}}get context(){return Mt(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:We.relay})}async subscribe(e,t){var i,n,s;this.isInitialized(),t?.transportType==="relay"&&await this.toEstablishConnection();let o=typeof((i=t?.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(n=t?.internal)==null?void 0:n.throwOnFailedPublish,a=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"",f,u=g=>{g.topic===e&&(this.subscriber.off(bi.created,u),f())};return await Promise.all([new Promise(g=>{f=g,this.subscriber.on(bi.created,u)}),new Promise(async(g,y)=>{a=await this.subscriber.subscribe(e,Hw({internal:{throwOnFailedPublish:o}},t)).catch(S=>{o&&y(S)})||a,g()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(e=>e.promise))}catch(e){this.logger.warn(e)}this.hasExperiencedNetworkDisruption||this.connected?await rs(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(t,i)=>{let n=()=>{this.provider.off(gr.disconnect,n),i(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(gr.disconnect,n),await rs(this.provider.connect(),(0,ne.toMiliseconds)(ne.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{i(s)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,t()})}catch(t){this.logger.error(t);let i=t;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(i.message))throw t}finally{this.connectionAttemptInProgress=!1}}async restartTransport(e){this.connectionAttemptInProgress||(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Al())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((i,n)=>i.publishedAt-n.publishedAt);this.logger.trace(`Batch of ${t.length} message events sorted`);for(let i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){let{topic:i}=e;if(!t.sessionExists){let n=ut(ne.FIVE_MINUTES),s={topic:i,expiry:n,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,s)}this.events.emit(Ut.message,e),await this.recordMessageEvent(e)}startPingTimeout(){var e,t,i,n,s;if(wa())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((s=(n=(i=this.provider)==null?void 0:i.connection)==null?void 0:n.socket)==null||s.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o)}}isConnectionStalled(e){return this.staleConnectionErrors.some(t=>e.includes(t))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Zf(new eu(Gv({sdkVersion:Gl,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(e){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.debug(`Ignoring message for non-subscribed topic ${t}`),!0;let n=this.messages.has(t,i);return n&&this.logger.debug(`Ignoring duplicate message: ${i}`),n}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),fo(e)){if(!e.method.endsWith(lI))return;let t=e.params,{topic:i,message:n,publishedAt:s,attestation:o}=t.data,a={topic:i,message:n,publishedAt:s,transportType:We.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Hw({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else hn(e)&&this.events.emit(Ut.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Ut.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=co(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(gr.payload,this.onPayloadHandler),this.provider.off(gr.connect,this.onConnectHandler),this.provider.off(gr.disconnect,this.onDisconnectHandler),this.provider.off(gr.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Al();Ny(async t=>{e!==t&&(e=t,t?await this.restartTransport().catch(i=>this.logger.error(i)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(Ut.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e))},(0,ne.toMiliseconds)(pI))))}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(e=>{let t=setInterval(()=>{this.connected&&(clearInterval(t),e())},this.connectionStatusPollingInterval)}),await this.transportOpen())}},cM=Object.defineProperty,Gw=Object.getOwnPropertySymbols,fM=Object.prototype.hasOwnProperty,uM=Object.prototype.propertyIsEnumerable,Ww=(r,e,t)=>e in r?cM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Jw=(r,e)=>{for(var t in e||(e={}))fM.call(e,t)&&Ww(r,t,e[t]);if(Gw)for(var t of Gw(e))uM.call(e,t)&&Ww(r,t,e[t]);return r},wi=class extends Dc{constructor(e,t,i,n=yi,s=void 0){super(e,t,i,n),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version=gI,this.cached=[],this.initialized=!1,this.storagePrefix=yi,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!St(o)?this.map.set(this.getKey(o),o):by(o)?this.map.set(o.id,o):vy(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)},this.set=async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())},this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(f=>(0,t2.default)(a[f],o[f]))):this.values),this.update=async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let f=Jw(Jw({},this.getData(o)),a);this.map.set(o,f),await this.persist()},this.delete=async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())},this.logger=wt(t,this.name),this.storagePrefix=n,this.getKey=s}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},f0=class{constructor(e,t){this.core=e,this.logger=t,this.name=wI,this.version=xI,this.events=new Bi.default,this.initialized=!1,this.storagePrefix=yi,this.ignoredPayloadTypes=[Rr],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]},this.create=async i=>{this.isInitialized();let n=kf(),s=await this.core.crypto.setSymKey(n),o=ut(ne.FIVE_MINUTES),a={protocol:b0},f={topic:s,expiry:o,relay:a,active:!1,methods:i?.methods},u=wl({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:n,relay:a,expiryTimestamp:o,methods:i?.methods});return this.events.emit(pn.create,f),this.core.expirer.set(s,o),await this.pairings.set(s,f),await this.core.relayer.subscribe(s,{transportType:i?.transportType}),{topic:s,uri:u}},this.pair=async i=>{this.isInitialized();let n=this.core.eventClient.createEvent({properties:{topic:i?.uri,trace:[Lr.pairing_started]}});this.isValidPair(i,n);let{topic:s,symKey:o,relay:a,expiryTimestamp:f,methods:u}=yl(i.uri);n.props.properties.topic=s,n.addTrace(Lr.pairing_uri_validation_success),n.addTrace(Lr.pairing_uri_not_expired);let g;if(this.pairings.keys.includes(s)){if(g=this.pairings.get(s),n.addTrace(Lr.existing_pairing),g.active)throw n.setError(vi.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);n.addTrace(Lr.pairing_not_expired)}let y=f||ut(ne.FIVE_MINUTES),S={topic:s,relay:a,expiry:y,active:!1,methods:u};this.core.expirer.set(s,y),await this.pairings.set(s,S),n.addTrace(Lr.store_new_pairing),i.activatePairing&&await this.activate({topic:s}),this.events.emit(pn.create,S),n.addTrace(Lr.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(o,s),n.addTrace(Lr.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{n.setError(vi.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:a})}catch(I){throw n.setError(vi.subscribe_pairing_topic_failure),I}return n.addTrace(Lr.subscribe_pairing_topic_success),S},this.activate=async({topic:i})=>{this.isInitialized();let n=ut(ne.THIRTY_DAYS);this.core.expirer.set(i,n),await this.pairings.update(i,{active:!0,expiry:n})},this.ping=async i=>{this.isInitialized(),await this.isValidPing(i);let{topic:n}=i;if(this.pairings.keys.includes(n)){let s=await this.sendRequest(n,"wc_pairingPing",{}),{done:o,resolve:a,reject:f}=Fi();this.events.once(Fe("pairing_ping",s),({error:u})=>{u?f(u):a()}),await o()}},this.updateExpiry=async({topic:i,expiry:n})=>{this.isInitialized(),await this.pairings.update(i,{expiry:n})},this.updateMetadata=async({topic:i,metadata:n})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:n})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async i=>{this.isInitialized(),await this.isValidDisconnect(i);let{topic:n}=i;this.pairings.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",ke("USER_DISCONNECTED")),await this.deletePairing(n))},this.formatUriFromPairing=i=>{this.isInitialized();let{topic:n,relay:s,expiry:o,methods:a}=i,f=this.core.crypto.keychain.get(n);return wl({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:f,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=async(i,n,s)=>{let o=Cr(n,s),a=await this.core.crypto.encode(i,o),f=Ua[n].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,f),o.id},this.sendResult=async(i,n,s)=>{let o=co(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=Ua[f.request.method].res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.sendError=async(i,n,s)=>{let o=is(i,s),a=await this.core.crypto.encode(n,o),f=await this.core.history.get(n,i),u=Ua[f.request.method]?Ua[f.request.method].res:Ua.unregistered_method.res;await this.core.relayer.publish(n,a,u),await this.core.history.resolve(o)},this.deletePairing=async(i,n)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,ke("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),n?Promise.resolve():this.core.expirer.del(i)])},this.cleanup=async()=>{let i=this.pairings.getAll().filter(n=>li(n.expiry));await Promise.all(i.map(n=>this.deletePairing(n.topic)))},this.onRelayEventRequest=i=>{let{topic:n,payload:s}=i;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(n,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,s);default:return this.onUnknownRpcMethodRequest(n,s)}},this.onRelayEventResponse=async i=>{let{topic:n,payload:s}=i,o=(await this.core.history.get(n,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(n,s);default:return this.onUnknownRpcMethodResponse(o)}},this.onPairingPingRequest=async(i,n)=>{let{id:s}=n;try{this.isValidPing({topic:i}),await this.sendResult(s,i,!0),this.events.emit(pn.ping,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onPairingPingResponse=(i,n)=>{let{id:s}=n;setTimeout(()=>{Xt(n)?this.events.emit(Fe("pairing_ping",s),{}):Lt(n)&&this.events.emit(Fe("pairing_ping",s),{error:n.error})},500)},this.onPairingDeleteRequest=async(i,n)=>{let{id:s}=n;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(pn.delete,{id:s,topic:i})}catch(o){await this.sendError(s,i,o),this.logger.error(o)}},this.onUnknownRpcMethodRequest=async(i,n)=>{let{id:s,method:o}=n;try{if(this.registeredMethods.includes(o))return;let a=ke("WC_METHOD_UNSUPPORTED",o);await this.sendError(s,i,a),this.logger.error(a)}catch(a){await this.sendError(s,i,a),this.logger.error(a)}},this.onUnknownRpcMethodResponse=i=>{this.registeredMethods.includes(i)||this.logger.error(ke("WC_METHOD_UNSUPPORTED",i))},this.isValidPair=(i,n)=>{var s;if(!Ot(i)){let{message:a}=Q("MISSING_OR_INVALID",`pair() params: ${i}`);throw n.setError(vi.malformed_pairing_uri),new Error(a)}if(!my(i.uri)){let{message:a}=Q("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw n.setError(vi.malformed_pairing_uri),new Error(a)}let o=yl(i?.uri);if(!((s=o?.relay)!=null&&s.protocol)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#relay-protocol");throw n.setError(vi.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=Q("MISSING_OR_INVALID","pair() uri#symKey");throw n.setError(vi.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0,ne.toMiliseconds)(o?.expiryTimestamp){if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidDisconnect=async i=>{if(!Ot(i)){let{message:s}=Q("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(s)}let{topic:n}=i;await this.isValidPairingTopic(n)},this.isValidPairingTopic=async i=>{if(!et(i,!1)){let{message:n}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(n)}if(!this.pairings.keys.includes(i)){let{message:n}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(n)}if(li(this.pairings.get(i).expiry)){await this.deletePairing(i);let{message:n}=Q("EXPIRED",`pairing topic: ${i}`);throw new Error(n)}},this.core=e,this.logger=wt(t,this.name),this.pairings=new wi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Mt(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ut.message,async e=>{let{topic:t,message:i,transportType:n}=e;if(!this.pairings.keys.includes(t)||n===We.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{fo(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):hn(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(Qt.expired,async e=>{let{topic:t}=qf(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(pn.expire,{topic:t}))})}},u0=class extends Tc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new Bi.EventEmitter,this.name=_I,this.version=EI,this.cached=[],this.initialized=!1,this.storagePrefix=yi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(i,n,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:n,chainId:s}),this.records.has(n.id))return;let o={id:n.id,topic:i,request:{method:n.method,params:n.params||null},chainId:s,expiry:ut(ne.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Or.created,o)},this.resolve=async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;let n=await this.getRecord(i.id);typeof n.response>"u"&&(n.response=Lt(i)?{error:i.error}:{result:i.result},this.records.set(n.id,n),this.persist(),this.events.emit(Or.updated,n))},this.get=async(i,n)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:n}),await this.getRecord(n)),this.delete=(i,n)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:n}),this.values.forEach(s=>{if(s.topic===i){if(typeof n<"u"&&s.id!==n)return;this.records.delete(s.id),this.events.emit(Or.deleted,s)}}),this.persist()},this.exists=async(i,n)=>(this.isInitialized(),this.records.has(n)?(await this.getRecord(n)).topic===i:!1),this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){let e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;let i={topic:t.topic,request:Cr(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();let t=this.records.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Or.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Or.created,e=>{let t=Or.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.updated,e=>{let t=Or.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(Or.deleted,e=>{let t=Or.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(Un.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,ne.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(Or.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},h0=class extends Oc{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new Bi.EventEmitter,this.name=SI,this.version=II,this.cached=[],this.initialized=!1,this.storagePrefix=yi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=i=>{try{let n=this.formatTarget(i);return typeof this.getExpiration(n)<"u"}catch{return!1}},this.set=(i,n)=>{this.isInitialized();let s=this.formatTarget(i),o={target:s,expiry:n};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Qt.created,{target:s,expiration:o})},this.get=i=>{this.isInitialized();let n=this.formatTarget(i);return this.getExpiration(n)},this.del=i=>{if(this.isInitialized(),this.has(i)){let n=this.formatTarget(i),s=this.getExpiration(n);this.expirations.delete(n),this.events.emit(Qt.deleted,{target:n,expiration:s})}},this.on=(i,n)=>{this.events.on(i,n)},this.once=(i,n)=>{this.events.once(i,n)},this.off=(i,n)=>{this.events.off(i,n)},this.removeListener=(i,n)=>{this.events.removeListener(i,n)},this.logger=wt(t,this.name)}get context(){return Mt(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Jv(e);if(typeof e=="number")return Yv(e);let{message:t}=Q("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Qt.sync)}async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:t}=Q("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){let t=this.expirations.get(e);if(!t){let{message:i}=Q("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,ne.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Qt.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Un.pulse,()=>this.checkExpirations()),this.events.on(Qt.created,e=>{let t=Qt.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Qt.expired,e=>{let t=Qt.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Qt.deleted,e=>{let t=Qt.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}},d0=class extends Lc{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,this.name=AI,this.verifyUrlV3=TI,this.storagePrefix=yi,this.version=n2,this.init=async()=>{var n;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,ne.toMiliseconds)((n=this.publicKey)==null?void 0:n.expiresAt){if(!eo()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:a}=n,f=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{let u=(0,r2.getDocument)(),g=this.startAbortTimer(ne.ONE_SECOND*5),y=await new Promise((S,I)=>{let A=()=>{window.removeEventListener("message",O),u.body.removeChild(P),I("attestation aborted")};this.abortController.signal.addEventListener("abort",A);let P=u.createElement("iframe");P.src=f,P.style.display="none",P.addEventListener("error",A,{signal:this.abortController.signal});let O=N=>{if(N.data&&typeof N.data=="string")try{let U=JSON.parse(N.data);if(U.type==="verify_attestation"){if(Os(U.attestation).payload.id!==o)return;clearInterval(g),u.body.removeChild(P),this.abortController.signal.removeEventListener("abort",A),window.removeEventListener("message",O),S(U.attestation===null?"":U.attestation)}}catch(U){this.logger.warn(U)}};u.body.appendChild(P),window.addEventListener("message",O,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",y),y}catch(u){this.logger.warn(u)}return""},this.resolve=async n=>{if(this.isDevEnv)return"";let{attestationId:s,hash:o,encryptedId:a}=n;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(Os(s).payload.id!==a)return;let u=await this.isValidJwtAttestation(s);if(u){if(!u.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return u}}if(!o)return;let f=this.getVerifyUrl(n?.verifyUrl);return this.fetchAttestation(o,f)},this.fetchAttestation=async(n,s)=>{this.logger.debug(`resolving attestation: ${n} from url: ${s}`);let o=this.startAbortTimer(ne.ONE_SECOND*5),a=await fetch(`${s}/attestation/${n}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0},this.getVerifyUrl=n=>{let s=n||po;return PI.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${po}`),s=po),s},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let n=this.startAbortTimer(ne.FIVE_SECONDS),s=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(n),await s.json()}catch(n){this.logger.warn(n)}},this.persistPublicKey=async n=>{this.logger.debug("persisting public key to local storage",n),await this.store.setItem(this.storeKey,n),this.publicKey=n},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async n=>{let s=await this.getPublicKey();try{if(s)return this.validateAttestation(n,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}let o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(n,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async s=>{let o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),s(o))});let n=await this.fetchPromise;return this.fetchPromise=void 0,n},this.validateAttestation=(n,s)=>{let o=py(n,s.publicKey),a={hasExpired:(0,ne.toMiliseconds)(o.exp)this.abortController.abort(),(0,ne.toMiliseconds)(e))}},l0=class extends Fc{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.context=RI,this.registerDeviceToken=async i=>{let{clientId:n,token:s,notificationType:o,enableEncrypted:a=!1}=i,f=`${NI}/${this.projectId}/clients`;await fetch(f,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:n,type:o,token:s,always_raw:a})})},this.logger=wt(t,this.context)}},hM=Object.defineProperty,Yw=Object.getOwnPropertySymbols,dM=Object.prototype.hasOwnProperty,lM=Object.prototype.propertyIsEnumerable,Xw=(r,e,t)=>e in r?hM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ba=(r,e)=>{for(var t in e||(e={}))dM.call(e,t)&&Xw(r,t,e[t]);if(Yw)for(var t of Yw(e))lM.call(e,t)&&Xw(r,t,e[t]);return r},p0=class extends Uc{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,this.context=CI,this.storagePrefix=yi,this.storageVersion=DI,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!_a())try{let n={eventId:fl(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:sl(this.core.relayer.protocol,this.core.relayer.version,Gl)}}};await this.sendEvent([n])}catch(n){this.logger.warn(n)}},this.createEvent=n=>{let{event:s="ERROR",type:o="",properties:{topic:a,trace:f}}=n,u=fl(),g=this.core.projectId||"",y=Date.now(),S=Ba({eventId:u,timestamp:y,props:{event:s,type:o,properties:{topic:a,trace:f}},bundleId:g,domain:this.getAppDomain()},this.setMethods(u));return this.telemetryEnabled&&(this.events.set(u,S),this.shouldPersist=!0),S},this.getEvent=n=>{let{eventId:s,topic:o}=n;if(s)return this.events.get(s);let a=Array.from(this.events.values()).find(f=>f.props.properties.topic===o);if(a)return Ba(Ba({},a),this.setMethods(a.eventId))},this.deleteEvent=n=>{let{eventId:s}=n;this.events.delete(s),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(Un.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(n=>{(0,ne.fromMiliseconds)(Date.now())-(0,ne.fromMiliseconds)(n.timestamp)>OI&&(this.events.delete(n.eventId),this.shouldPersist=!0)})})},this.setMethods=n=>({addTrace:s=>this.addTrace(n,s),setError:s=>this.setError(n,s)}),this.addTrace=(n,s)=>{let o=this.events.get(n);o&&(o.props.properties.trace.push(s),this.events.set(n,o),this.shouldPersist=!0)},this.setError=(n,s)=>{let o=this.events.get(n);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(n,o),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{let n=await this.core.storage.getItem(this.storageKey)||[];if(!n.length)return;n.forEach(s=>{this.events.set(s.eventId,Ba(Ba({},s),this.setMethods(s.eventId)))})}catch(n){this.logger.warn(n)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;let n=[];for(let[s,o]of this.events)o.props.type&&n.push(o);if(n.length!==0)try{if((await this.sendEvent(n)).ok)for(let s of n)this.events.delete(s.eventId),this.shouldPersist=!0}catch(s){this.logger.warn(s)}},this.sendEvent=async n=>{let s=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${LI}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Gl}${s}`,{method:"POST",body:JSON.stringify(n)})},this.getAppDomain=()=>to().url,this.logger=wt(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},pM=Object.defineProperty,Qw=Object.getOwnPropertySymbols,gM=Object.prototype.hasOwnProperty,mM=Object.prototype.propertyIsEnumerable,Zw=(r,e,t)=>e in r?pM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,e2=(r,e)=>{for(var t in e||(e={}))gM.call(e,t)&&Zw(r,t,e[t]);if(Qw)for(var t of Qw(e))mM.call(e,t)&&Zw(r,t,e[t]);return r},g0=class r extends Mc{constructor(e){var t;super(e),this.protocol=i2,this.version=n2,this.name=m0,this.events=new Bi.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:f})=>{if(!o||!a)return;let u={topic:o,message:a,publishedAt:Date.now(),transportType:We.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:f})},this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||s2,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let i=Vo({level:typeof e?.logger=="string"&&e.logger?e.logger:tI.logger}),{logger:n,chunkLoggerController:s}=yg({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=s,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=wt(n,this.name),this.heartbeat=new bc,this.crypto=new i0(this,this.logger,e?.keychain),this.history=new u0(this,this.logger),this.expirer=new h0(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new wc(e2(e2({},rI),e?.storageOptions)),this.relayer=new c0({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new f0(this,this.logger),this.verify=new d0(this,this.logger,this.storage),this.echoClient=new l0(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new p0(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new r(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem(mI,i),t}get context(){return Mt(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Lw,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(Lw)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}},b2=g0;var gu=Be(Fn()),qe=Be(_s());var x2="wc",_2=2,E2="client",T0=`${x2}@${_2}:${E2}:`,v0={name:E2,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"};var v2="WALLETCONNECT_DEEPLINK_CHOICE";var bM="proposal";var vM="Proposal expired",yM="session",mo=qe.SEVEN_DAYS,wM="engine",vt={wc_sessionPropose:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1104},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1106},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:qe.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1112},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:qe.ONE_DAY,prompt:!1,tag:1114},res:{ttl:qe.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:qe.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:qe.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:qe.FIVE_MINUTES,prompt:!1,tag:1119}}},y0={min:qe.FIVE_MINUTES,max:qe.SEVEN_DAYS},xi={idle:"IDLE",active:"ACTIVE"},xM="request",_M=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],EM="wc";var SM="auth",IM="authKeys",AM="pairingTopics",MM="requests",mu=`${EM}@${1.5}:${SM}:`,lu=`${mu}:PUB_KEY`,TM=Object.defineProperty,PM=Object.defineProperties,RM=Object.getOwnPropertyDescriptors,y2=Object.getOwnPropertySymbols,NM=Object.prototype.hasOwnProperty,DM=Object.prototype.propertyIsEnumerable,w2=(r,e,t)=>e in r?TM(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,st=(r,e)=>{for(var t in e||(e={}))NM.call(e,t)&&w2(r,t,e[t]);if(y2)for(var t of y2(e))DM.call(e,t)&&w2(r,t,e[t]);return r},Fr=(r,e)=>PM(r,RM(e)),w0=class extends Bc{constructor(e){super(e),this.name=wM,this.events=new gu.default,this.initialized=!1,this.requestQueue={state:xi.idle,queue:[]},this.sessionRequestQueue={state:xi.idle,queue:[]},this.requestQueueDelay=qe.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(vt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay)))},this.connect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let i=Fr(st({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);let{pairingTopic:n,requiredNamespaces:s,optionalNamespaces:o,sessionProperties:a,relays:f}=i,u=n,g,y=!1;try{u&&(y=this.client.core.pairing.pairings.get(u).active)}catch(B){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),B}if(!u||!y){let{topic:B,uri:j}=await this.client.core.pairing.create();u=B,g=j}if(!u){let{message:B}=Q("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(B)}let S=await this.client.core.crypto.generateKeyPair(),I=vt.wc_sessionPropose.req.ttl||qe.FIVE_MINUTES,A=ut(I),P=st({requiredNamespaces:s,optionalNamespaces:o,relays:f??[{protocol:b0}],proposer:{publicKey:S,metadata:this.client.metadata},expiryTimestamp:A,pairingTopic:u},a&&{sessionProperties:a}),{reject:O,resolve:N,done:U}=Fi(I,vM);this.events.once(Fe("session_connect"),async({error:B,session:j})=>{if(B)O(B);else if(j){j.self.publicKey=S;let V=Fr(st({},j),{pairingTopic:P.pairingTopic,requiredNamespaces:P.requiredNamespaces,optionalNamespaces:P.optionalNamespaces,transportType:We.relay});await this.client.session.set(j.topic,V),await this.setExpiry(j.topic,j.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:j.peer.metadata}),this.cleanupDuplicatePairings(V),N(V)}});let k=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:P,throwOnFailedPublish:!0});return await this.setProposal(k,st({id:k},P)),{uri:g,approval:U}},this.pair=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}},this.approve=async t=>{var i,n,s;let o=this.client.core.eventClient.createEvent({properties:{topic:(i=t?.id)==null?void 0:i.toString(),trace:[mr.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(C){throw o.setError(gn.no_internet_connection),C}try{await this.isValidProposalId(t?.id)}catch(C){throw this.client.logger.error(`approve() -> proposal.get(${t?.id}) failed`),o.setError(gn.proposal_not_found),C}try{await this.isValidApprove(t)}catch(C){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(gn.session_approve_namespace_validation_failure),C}let{id:a,relayProtocol:f,namespaces:u,sessionProperties:g,sessionConfig:y}=t,S=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});let{pairingTopic:I,proposer:A,requiredNamespaces:P,optionalNamespaces:O}=S,N=(n=this.client.core.eventClient)==null?void 0:n.getEvent({topic:I});N||(N=(s=this.client.core.eventClient)==null?void 0:s.createEvent({type:mr.session_approve_started,properties:{topic:I,trace:[mr.session_approve_started,mr.session_namespaces_validation_success]}}));let U=await this.client.core.crypto.generateKeyPair(),k=A.publicKey,B=await this.client.core.crypto.generateSharedKey(U,k),j=st(st({relay:{protocol:f??"irn"},namespaces:u,controller:{publicKey:U,metadata:this.client.metadata},expiry:ut(mo)},g&&{sessionProperties:g}),y&&{sessionConfig:y}),V=We.relay;N.addTrace(mr.subscribing_session_topic);try{await this.client.core.relayer.subscribe(B,{transportType:V})}catch(C){throw N.setError(gn.subscribe_session_topic_failure),C}N.addTrace(mr.subscribe_session_topic_success);let L=Fr(st({},j),{topic:B,requiredNamespaces:P,optionalNamespaces:O,pairingTopic:I,acknowledged:!1,self:j.controller,peer:{publicKey:A.publicKey,metadata:A.metadata},controller:U,transportType:We.relay});await this.client.session.set(B,L),N.addTrace(mr.store_session);try{N.addTrace(mr.publishing_session_settle),await this.sendRequest({topic:B,method:"wc_sessionSettle",params:j,throwOnFailedPublish:!0}).catch(C=>{throw N?.setError(gn.session_settle_publish_failure),C}),N.addTrace(mr.session_settle_publish_success),N.addTrace(mr.publishing_session_approve),await this.sendResult({id:a,topic:I,result:{relay:{protocol:f??"irn"},responderPublicKey:U},throwOnFailedPublish:!0}).catch(C=>{throw N?.setError(gn.session_approve_publish_failure),C}),N.addTrace(mr.session_approve_publish_success)}catch(C){throw this.client.logger.error(C),this.client.session.delete(B,ke("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(B),C}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:I,metadata:A.metadata}),await this.client.proposal.delete(a,ke("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:I}),await this.setExpiry(B,ut(mo)),{topic:B,acknowledged:()=>Promise.resolve(this.client.session.get(B))}},this.reject=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}let{id:i,reason:n}=t,s;try{s=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}s&&(await this.sendError({id:i,topic:s,error:n,rpcOpts:vt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED")))},this.update=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(y){throw this.client.logger.error("update() -> isValidUpdate() failed"),y}let{topic:i,namespaces:n}=t,{done:s,resolve:o,reject:a}=Fi(),f=gi(),u=Dr().toString(),g=this.client.session.get(i).namespaces;return this.events.once(Fe("session_update",f),({error:y})=>{y?a(y):o()}),await this.client.session.update(i,{namespaces:n}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:f,relayRpcId:u}).catch(y=>{this.client.logger.error(y),this.client.session.update(i,{namespaces:g}),a(y)}),{acknowledged:s}},this.extend=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(f){throw this.client.logger.error("extend() -> isValidExtend() failed"),f}let{topic:i}=t,n=gi(),{done:s,resolve:o,reject:a}=Fi();return this.events.once(Fe("session_extend",n),({error:f})=>{f?a(f):o()}),await this.setExpiry(i,ut(mo)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(f=>{a(f)}),{acknowledged:s}},this.request=async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(A){throw this.client.logger.error("request() -> isValidRequest() failed"),A}let{chainId:i,request:n,topic:s,expiry:o=vt.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(s);a?.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let f=gi(),u=Dr().toString(),{done:g,resolve:y,reject:S}=Fi(o,"Request expired. Please try again.");this.events.once(Fe("session_request",f),({error:A,result:P})=>{A?S(A):y(P)});let I=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);return I?(await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:I}).catch(A=>S(A)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),await g()):await Promise.all([new Promise(async A=>{await this.sendRequest({clientRpcId:f,relayRpcId:u,topic:s,method:"wc_sessionRequest",params:{request:Fr(st({},n),{expiryTimestamp:ut(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0}).catch(P=>S(P)),this.client.events.emit("session_request_sent",{topic:s,request:n,chainId:i,id:f}),A()}),new Promise(async A=>{var P;if(!((P=a.sessionConfig)!=null&&P.disableDeepLink)){let O=await Qv(this.client.core.storage,v2);await Xv({id:f,topic:s,wcDeepLink:O})}A()}),g()]).then(A=>A[2])},this.respond=async t=>{this.isInitialized(),await this.isValidRespond(t);let{topic:i,response:n}=t,{id:s}=n,o=this.client.session.get(i);o.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);Xt(n)?await this.sendResult({id:s,topic:i,result:n.result,throwOnFailedPublish:!0,appLink:a}):Lt(n)&&await this.sendError({id:s,topic:i,error:n.error,appLink:a}),this.cleanupAfterResponse(t)},this.ping=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}let{topic:i}=t;if(this.client.session.keys.includes(i)){let n=gi(),s=Dr().toString(),{done:o,resolve:a,reject:f}=Fi();this.events.once(Fe("session_ping",n),({error:u})=>{u?f(u):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:n,relayRpcId:s}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&await this.client.core.pairing.ping({topic:i})},this.emit=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);let{topic:i,event:n,chainId:s}=t,o=Dr().toString();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:n,chainId:s},throwOnFailedPublish:!0,relayRpcId:o})},this.disconnect=async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);let{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:ke("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{let{message:n}=Q("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(n)}},this.find=t=>(this.isInitialized(),this.client.session.getAll().filter(i=>gy(i,t))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(t,i)=>{var n;this.isInitialized(),this.isValidAuthenticate(t);let s=i&&this.client.core.linkModeSupportedApps.includes(i)&&((n=this.client.metadata.redirect)==null?void 0:n.linkMode),o=s?We.link_mode:We.relay;o===We.relay&&await this.confirmOnlineStateOrThrow();let{chains:a,statement:f="",uri:u,domain:g,nonce:y,type:S,exp:I,nbf:A,methods:P=[],expiry:O}=t,N=[...t.resources||[]],{topic:U,uri:k}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:U,uri:k}});let B=await this.client.core.crypto.generateKeyPair(),j=no(B);if(await Promise.all([this.client.auth.authKeys.set(lu,{responseTopic:j,publicKey:B}),this.client.auth.pairingTopics.set(j,{topic:j,pairingTopic:U})]),await this.client.core.relayer.subscribe(j,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${U}`),P.length>0){let{namespace:v}=ya(a[0]),h=ty(v,"request",P);Sa(N)&&(h=ry(h,N.pop())),N.push(h)}let V=O&&O>vt.wc_sessionAuthenticate.req.ttl?O:vt.wc_sessionAuthenticate.req.ttl,L={authPayload:{type:S??"caip122",chains:a,statement:f,aud:u,domain:g,version:"1",nonce:y,iat:new Date().toISOString(),exp:I,nbf:A,resources:N},requester:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(V)},C={eip155:{chains:a,methods:[...new Set(["personal_sign",...P])],events:["chainChanged","accountsChanged"]}},W={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:U,proposer:{publicKey:B,metadata:this.client.metadata},expiryTimestamp:ut(vt.wc_sessionPropose.req.ttl)},{done:R,resolve:l,reject:w}=Fi(V,"Request expired"),p=async({error:v,session:h})=>{if(this.events.off(Fe("session_request",d),c),v)w(v);else if(h){h.self.publicKey=B,await this.client.session.set(h.topic,h),await this.setExpiry(h.topic,h.expiry),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:h.peer.metadata});let _=this.client.session.get(h.topic);await this.deleteProposal(b),l({session:_})}},c=async v=>{var h,_,M;if(await this.deletePendingAuthRequest(d,{message:"fulfilled",code:0}),v.error){let q=ke("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return v.error.code===q.code?void 0:(this.events.off(Fe("session_connect"),p),w(v.error.message))}await this.deleteProposal(b),this.events.off(Fe("session_connect"),p);let{cacaos:m,responder:T}=v.result,z=[],E=[];for(let q of m){await hl({cacao:q,projectId:this.client.core.projectId})||(this.client.logger.error(q,"Signature verification failed"),w(ke("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:K}=q,Y=Sa(K.resources),H=[Bf(K.iss)],$=Ea(K.iss);if(Y){let ee=ll(Y),G=pl(Y);z.push(...ee),H.push(...G)}for(let ee of H)E.push(`${ee}:${$}`)}let D=await this.client.core.crypto.generateSharedKey(B,T.publicKey),F;z.length>0&&(F={topic:D,acknowledged:!0,self:{publicKey:B,metadata:this.client.metadata},peer:T,controller:T.publicKey,expiry:ut(mo),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:U,namespaces:xl([...new Set(z)],[...new Set(E)]),transportType:o},await this.client.core.relayer.subscribe(D,{transportType:o}),await this.client.session.set(D,F),U&&await this.client.core.pairing.updateMetadata({topic:U,metadata:T.metadata}),F=this.client.session.get(D)),(h=this.client.metadata.redirect)!=null&&h.linkMode&&(_=T.metadata.redirect)!=null&&_.linkMode&&(M=T.metadata.redirect)!=null&&M.universal&&i&&(this.client.core.addLinkModeSupportedApp(T.metadata.redirect.universal),this.client.session.update(D,{transportType:We.link_mode})),l({auths:m,session:F})},d=gi(),b=gi();this.events.once(Fe("session_connect"),p),this.events.once(Fe("session_request",d),c);let x;try{if(s){let v=Cr("wc_sessionAuthenticate",L,d);this.client.core.history.set(U,v);let h=await this.client.core.crypto.encode("",v,{type:io,encoding:ro});x=Aa(i,U,h)}else await Promise.all([this.sendRequest({topic:U,method:"wc_sessionAuthenticate",params:L,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:d}),this.sendRequest({topic:U,method:"wc_sessionPropose",params:W,expiry:vt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:b})])}catch(v){throw this.events.off(Fe("session_connect"),p),this.events.off(Fe("session_request",d),c),v}return await this.setProposal(b,st({id:b},W)),await this.setAuthRequest(d,{request:Fr(st({},L),{verifyContext:{}}),pairingTopic:U,transportType:o}),{uri:x??k,response:R}},this.approveSessionAuthenticate=async t=>{let{id:i,auths:n}=t,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[mn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(O){throw s.setError(go.no_internet_connection),O}let o=this.getPendingAuthRequest(i);if(!o)throw s.setError(go.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);let a=o.transportType||We.relay;a===We.relay&&await this.confirmOnlineStateOrThrow();let f=o.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),g=no(f),y={type:Rr,receiverPublicKey:f,senderPublicKey:u},S=[],I=[];for(let O of n){if(!await hl({cacao:O,projectId:this.client.core.projectId})){s.setError(go.invalid_cacao);let j=ke("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:g,error:j,encodeOpts:y}),new Error(j.message)}s.addTrace(mn.cacaos_verified);let{p:N}=O,U=Sa(N.resources),k=[Bf(N.iss)],B=Ea(N.iss);if(U){let j=ll(U),V=pl(U);S.push(...j),k.push(...V)}for(let j of k)I.push(`${j}:${B}`)}let A=await this.client.core.crypto.generateSharedKey(u,f);s.addTrace(mn.create_authenticated_session_topic);let P;if(S?.length>0){P={topic:A,acknowledged:!0,self:{publicKey:u,metadata:this.client.metadata},peer:{publicKey:f,metadata:o.requester.metadata},controller:f,expiry:ut(mo),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:xl([...new Set(S)],[...new Set(I)]),transportType:a},s.addTrace(mn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:a})}catch(O){throw s.setError(go.subscribe_authenticated_session_topic_failure),O}s.addTrace(mn.subscribe_authenticated_session_topic_success),await this.client.session.set(A,P),s.addTrace(mn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}s.addTrace(mn.publishing_authenticated_session_approve);try{await this.sendResult({topic:g,id:i,result:{cacaos:n,responder:{publicKey:u,metadata:this.client.metadata}},encodeOpts:y,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(O){throw s.setError(go.authenticated_session_approve_publish_failure),O}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:P}},this.rejectSessionAuthenticate=async t=>{this.isInitialized();let{id:i,reason:n}=t,s=this.getPendingAuthRequest(i);if(!s)throw new Error(`Could not find pending auth request with id ${i}`);s.transportType===We.relay&&await this.confirmOnlineStateOrThrow();let o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),f=no(o),u={type:Rr,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:f,error:n,encodeOpts:u,rpcOpts:vt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,ke("USER_DISCONNECTED"))},this.formatAuthMessage=t=>{this.isInitialized();let{request:i,iss:n}=t;return dl(i,n)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{let t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)},this.cleanupDuplicatePairings=async t=>{if(t.pairingTopic)try{let i=this.client.core.pairing.pairings.get(t.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(s=>{var o,a;return((o=s.peerMetadata)==null?void 0:o.url)&&((a=s.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&s.topic&&s.topic!==i.topic});if(n.length===0)return;this.client.logger.info(`Cleaning up ${n.length} duplicate pairing(s)`),await Promise.all(n.map(s=>this.client.core.pairing.disconnect({topic:s.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}},this.deleteSession=async t=>{var i;let{topic:n,expirerHasDeleted:s=!1,emitEvent:o=!0,id:a=0}=t,{self:f}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ke("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(f.publicKey)&&await this.client.core.crypto.deleteKeyPair(f.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),s||this.client.core.expirer.del(n),this.client.core.storage.removeItem(v2).catch(u=>this.client.logger.warn(u)),this.getPendingSessionRequests().forEach(u=>{u.topic===n&&this.deletePendingSessionRequest(u.id,ke("USER_DISCONNECTED"))}),n===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=xi.idle),o&&this.client.events.emit("session_delete",{id:a,topic:n})},this.deleteProposal=async(t,i)=>{if(i)try{let n=this.client.proposal.get(t);this.client.core.eventClient.getEvent({topic:n.pairingTopic})?.setError(gn.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,ke("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")},this.deletePendingSessionRequest=async(t,i,n=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(s=>s.id!==t),n&&(this.sessionRequestQueue.state=xi.idle,this.client.events.emit("session_request_expire",{id:t}))},this.deletePendingAuthRequest=async(t,i,n=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),n?Promise.resolve():this.client.core.expirer.del(t)])},this.setExpiry=async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))},this.setProposal=async(t,i)=>{this.client.core.expirer.set(t,ut(vt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)},this.setAuthRequest=async(t,i)=>{let{request:n,pairingTopic:s,transportType:o=We.relay}=i;this.client.core.expirer.set(t,n.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:t,pairingTopic:s,verifyContext:n.verifyContext,transportType:o})},this.setPendingSessionRequest=async t=>{let{id:i,topic:n,params:s,verifyContext:o}=t,a=s.request.expiryTimestamp||ut(vt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:n,params:s,verifyContext:o})},this.sendRequest=async t=>{let{topic:i,method:n,params:s,expiry:o,relayRpcId:a,clientRpcId:f,throwOnFailedPublish:u,appLink:g}=t,y=Cr(n,s,f),S,I=!!g;try{let O=I?ro:pi;S=await this.client.core.crypto.encode(i,y,{encoding:O})}catch(O){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),O}let A;if(_M.includes(n)){let O=Nr(JSON.stringify(y)),N=Nr(S);A=await this.client.core.verify.register({id:N,decryptedId:O})}let P=vt[n].req;if(P.attestation=A,o&&(P.ttl=o),a&&(P.id=a),this.client.core.history.set(i,y),I){let O=Aa(g,i,S);await global.Linking.openURL(O,this.client.name)}else{let O=vt[n].req;o&&(O.ttl=o),a&&(O.id=a),u?(O.internal=Fr(st({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,S,O)):this.client.core.relayer.publish(i,S,O).catch(N=>this.client.logger.error(N))}return y.id},this.sendResult=async t=>{let{id:i,topic:n,result:s,throwOnFailedPublish:o,encodeOpts:a,appLink:f}=t,u=co(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ro:pi;g=await this.client.core.crypto.encode(n,u,Fr(st({},a||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendResult() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Aa(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=vt[S.request.method].res;o?(I.internal=Fr(st({},I.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,I)):this.client.core.relayer.publish(n,g,I).catch(A=>this.client.logger.error(A))}await this.client.core.history.resolve(u)},this.sendError=async t=>{let{id:i,topic:n,error:s,encodeOpts:o,rpcOpts:a,appLink:f}=t,u=is(i,s),g,y=f&&typeof(global==null?void 0:global.Linking)<"u";try{let I=y?ro:pi;g=await this.client.core.crypto.encode(n,u,Fr(st({},o||{}),{encoding:I}))}catch(I){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),I}let S;try{S=await this.client.core.history.get(n,i)}catch(I){throw this.client.logger.error(`sendError() -> history.get(${n}, ${i}) failed`),I}if(y){let I=Aa(f,n,g);await global.Linking.openURL(I,this.client.name)}else{let I=a||vt[S.request.method].res;this.client.core.relayer.publish(n,g,I)}await this.client.core.history.resolve(u)},this.cleanup=async()=>{let t=[],i=[];this.client.session.getAll().forEach(n=>{let s=!1;li(n.expiry)&&(s=!0),this.client.core.crypto.keychain.has(n.topic)||(s=!0),s&&t.push(n.topic)}),this.client.proposal.getAll().forEach(n=>{li(n.expiryTimestamp)&&i.push(n.id)}),await Promise.all([...t.map(n=>this.deleteSession({topic:n})),...i.map(n=>this.deleteProposal(n))])},this.onRelayEventRequest=async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===xi.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=xi.active;let t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=xi.idle},this.processRequest=async t=>{let{topic:i,payload:n,attestation:s,transportType:o,encryptedId:a}=t,f=n.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:f}))switch(f){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:n,attestation:s,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,n);case"wc_sessionPing":return await this.onSessionPingRequest(i,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:n,attestation:s,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${f}`)}},this.onRelayEventResponse=async t=>{let{topic:i,payload:n,transportType:s}=t,o=(await this.client.core.history.get(i,n.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,n,s);case"wc_sessionSettle":return this.onSessionSettleResponse(i,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,n);case"wc_sessionExtend":return this.onSessionExtendResponse(i,n);case"wc_sessionPing":return this.onSessionPingResponse(i,n);case"wc_sessionRequest":return this.onSessionRequestResponse(i,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,n);default:return this.client.logger.info(`Unsupported response method ${o}`)}},this.onRelayEventUnknownPayload=t=>{let{topic:i}=t,{message:n}=Q("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(n)},this.shouldIgnorePairingRequest=t=>{let{topic:i,requestMethod:n}=t,s=this.expectedPairingMethodMap.get(i);return!s||s.includes(n)?!1:!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async t=>{let{topic:i,payload:n,attestation:s,encryptedId:o}=t,{params:a,id:f}=n;try{let u=this.client.core.eventClient.getEvent({topic:i});this.isValidConnect(st({},n.params));let g=a.expiryTimestamp||ut(vt.wc_sessionPropose.req.ttl),y=st({id:f,pairingTopic:i,expiryTimestamp:g},a);await this.setProposal(f,y);let S=await this.getVerifyContext({attestationId:s,hash:Nr(JSON.stringify(n)),encryptedId:o,metadata:y.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),u?.setError(vi.proposal_listener_not_found)),u?.addTrace(Lr.emit_session_proposal),this.client.events.emit("session_proposal",{id:f,params:y,verifyContext:S})}catch(u){await this.sendError({id:f,topic:i,error:u,rpcOpts:vt.wc_sessionPropose.autoReject}),this.client.logger.error(u)}},this.onSessionProposeResponse=async(t,i,n)=>{let{id:s}=i;if(Xt(i)){let{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});let a=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});let f=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:f});let u=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:u});let g=await this.client.core.crypto.generateSharedKey(f,u);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});let y=await this.client.core.relayer.subscribe(g,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:y}),await this.client.core.pairing.activate({topic:t})}else if(Lt(i)){await this.client.proposal.delete(s,ke("USER_DISCONNECTED"));let o=Fe("session_connect");if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(Fe("session_connect"),{error:i.error})}},this.onSessionSettleRequest=async(t,i)=>{let{id:n,params:s}=i;try{this.isValidSessionSettleRequest(s);let{relay:o,controller:a,expiry:f,namespaces:u,sessionProperties:g,sessionConfig:y}=i.params,S=Fr(st(st({topic:t,relay:o,expiry:f,namespaces:u,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:a.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},g&&{sessionProperties:g}),y&&{sessionConfig:y}),{transportType:We.relay}),I=Fe("session_connect");if(this.events.listenerCount(I)===0)throw new Error(`emitting ${I} without any listeners 997`);this.events.emit(Fe("session_connect"),{session:S}),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionSettleResponse=async(t,i)=>{let{id:n}=i;Xt(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Fe("session_approve",n),{})):Lt(i)&&(await this.client.session.delete(t,ke("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",n),{error:i.error}))},this.onSessionUpdateRequest=async(t,i)=>{let{params:n,id:s}=i;try{let o=`${t}_session_update`,a=on.get(o);if(a&&this.isRequestOutOfSync(a,s)){this.client.logger.info(`Discarding out of sync request - ${s}`),this.sendError({id:s,topic:t,error:ke("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(st({topic:t},n));try{on.set(o,s),await this.client.session.update(t,{namespaces:n.namespaces}),await this.sendResult({id:s,topic:t,result:!0,throwOnFailedPublish:!0})}catch(f){throw on.delete(o),f}this.client.events.emit("session_update",{id:s,topic:t,params:n})}catch(o){await this.sendError({id:s,topic:t,error:o}),this.client.logger.error(o)}},this.isRequestOutOfSync=(t,i)=>parseInt(i.toString().slice(0,-3))<=parseInt(t.toString().slice(0,-3)),this.onSessionUpdateResponse=(t,i)=>{let{id:n}=i,s=Fe("session_update",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Xt(i)?this.events.emit(Fe("session_update",n),{}):Lt(i)&&this.events.emit(Fe("session_update",n),{error:i.error})},this.onSessionExtendRequest=async(t,i)=>{let{id:n}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,ut(mo)),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionExtendResponse=(t,i)=>{let{id:n}=i,s=Fe("session_extend",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Xt(i)?this.events.emit(Fe("session_extend",n),{}):Lt(i)&&this.events.emit(Fe("session_extend",n),{error:i.error})},this.onSessionPingRequest=async(t,i)=>{let{id:n}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:t})}catch(s){await this.sendError({id:n,topic:t,error:s}),this.client.logger.error(s)}},this.onSessionPingResponse=(t,i)=>{let{id:n}=i,s=Fe("session_ping",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{Xt(i)?this.events.emit(Fe("session_ping",n),{}):Lt(i)&&this.events.emit(Fe("session_ping",n),{error:i.error})},500)},this.onSessionDeleteRequest=async(t,i)=>{let{id:n}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(s=>{this.client.core.relayer.once(Ut.publish,async()=>{s(await this.deleteSession({topic:t,id:n}))})}),this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:ke("USER_DISCONNECTED")})]).catch(s=>this.client.logger.error(s))}catch(s){this.client.logger.error(s)}},this.onSessionRequest=async t=>{var i,n,s;let{topic:o,payload:a,attestation:f,encryptedId:u,transportType:g}=t,{id:y,params:S}=a;try{await this.isValidRequest(st({topic:o},S));let I=this.client.session.get(o),A=await this.getVerifyContext({attestationId:f,hash:Nr(JSON.stringify(Cr("wc_sessionRequest",S,y))),encryptedId:u,metadata:I.peer.metadata,transportType:g}),P={id:y,topic:o,params:S,verifyContext:A};await this.setPendingSessionRequest(P),g===We.link_mode&&(i=I.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((n=I.peer.metadata.redirect)==null?void 0:n.universal),(s=this.client.signConfig)!=null&&s.disableRequestQueue?this.emitSessionRequest(P):(this.addSessionRequestToSessionRequestQueue(P),this.processSessionRequestQueue())}catch(I){await this.sendError({id:y,topic:o,error:I}),this.client.logger.error(I)}},this.onSessionRequestResponse=(t,i)=>{let{id:n}=i,s=Fe("session_request",n);if(this.events.listenerCount(s)===0)throw new Error(`emitting ${s} without any listeners`);Xt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionEventRequest=async(t,i)=>{let{id:n,params:s}=i;try{let o=`${t}_session_event_${s.event.name}`,a=on.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.info(`Discarding out of sync request - ${n}`);return}this.isValidEmit(st({topic:t},s)),this.client.events.emit("session_event",{id:n,topic:t,params:s}),on.set(o,n)}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}},this.onSessionAuthenticateResponse=(t,i)=>{let{id:n}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),Xt(i)?this.events.emit(Fe("session_request",n),{result:i.result}):Lt(i)&&this.events.emit(Fe("session_request",n),{error:i.error})},this.onSessionAuthenticateRequest=async t=>{var i;let{topic:n,payload:s,attestation:o,encryptedId:a,transportType:f}=t;try{let{requester:u,authPayload:g,expiryTimestamp:y}=s.params,S=await this.getVerifyContext({attestationId:o,hash:Nr(JSON.stringify(s)),encryptedId:a,metadata:u.metadata,transportType:f}),I={requester:u,pairingTopic:n,id:s.id,authPayload:g,verifyContext:S,expiryTimestamp:y};await this.setAuthRequest(s.id,{request:I,pairingTopic:n,transportType:f}),f===We.link_mode&&(i=u.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(u.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:s.params,id:s.id,verifyContext:S})}catch(u){this.client.logger.error(u);let g=s.params.requester.publicKey,y=await this.client.core.crypto.generateKeyPair(),S=this.getAppLinkIfEnabled(s.params.requester.metadata,f),I={type:Rr,receiverPublicKey:g,senderPublicKey:y};await this.sendError({id:s.id,topic:n,error:u,encodeOpts:I,rpcOpts:vt.wc_sessionAuthenticate.autoReject,appLink:S})}},this.addSessionRequestToSessionRequestQueue=t=>{this.sessionRequestQueue.queue.push(t)},this.cleanupAfterResponse=t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=xi.idle,this.processSessionRequestQueue()},(0,qe.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:t,error:i})=>{let n=this.client.core.history.pending;n.length>0&&n.filter(s=>s.topic===t&&s.request.method==="wc_sessionRequest").forEach(s=>{let o=s.request.id,a=Fe("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Fe("session_request",s.request.id),{error:i})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===xi.active){this.client.logger.info("session request queue is already active.");return}let t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=xi.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}},this.emitSessionRequest=t=>{this.client.events.emit("session_request",t)},this.onPairingCreated=t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;let i=this.client.proposal.getAll().find(n=>n.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:Cr("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})},this.isValidConnect=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(f)}let{pairingTopic:i,requiredNamespaces:n,optionalNamespaces:s,sessionProperties:o,relays:a}=t;if(St(i)||await this.isValidPairingTopic(i),!_y(a,!0)){let{message:f}=Q("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(f)}!St(n)&&Ma(n)!==0&&this.validateNamespaces(n,"requiredNamespaces"),!St(s)&&Ma(s)!==0&&this.validateNamespaces(s,"optionalNamespaces"),St(o)||this.validateSessionProps(o,"sessionProperties")},this.validateNamespaces=(t,i)=>{let n=xy(t,"connect()",i);if(n)throw new Error(n.message)},this.isValidApprove=async t=>{if(!Ot(t))throw new Error(Q("MISSING_OR_INVALID",`approve() params: ${t}`).message);let{id:i,namespaces:n,relayProtocol:s,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);let a=this.client.proposal.get(i),f=jf(n,"approve()");if(f)throw new Error(f.message);let u=Il(a.requiredNamespaces,n,"approve()");if(u)throw new Error(u.message);if(!et(s,!0)){let{message:g}=Q("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(g)}St(o)||this.validateSessionProps(o,"sessionProperties")},this.isValidReject=async t=>{if(!Ot(t)){let{message:s}=Q("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(s)}let{id:i,reason:n}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!Sy(n)){let{message:s}=Q("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(n)}`);throw new Error(s)}},this.isValidSessionSettleRequest=t=>{if(!Ot(t)){let{message:u}=Q("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(u)}let{relay:i,controller:n,namespaces:s,expiry:o}=t;if(!El(i)){let{message:u}=Q("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(u)}let a=yy(n,"onSessionSettleRequest()");if(a)throw new Error(a.message);let f=jf(s,"onSessionSettleRequest()");if(f)throw new Error(f.message);if(li(o)){let{message:u}=Q("EXPIRED","onSessionSettleRequest()");throw new Error(u)}},this.isValidUpdate=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(f)}let{topic:i,namespaces:n}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let s=this.client.session.get(i),o=jf(n,"update()");if(o)throw new Error(o.message);let a=Il(s.requiredNamespaces,n,"update()");if(a)throw new Error(a.message)},this.isValidExtend=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(n)}let{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)},this.isValidRequest=async t=>{if(!Ot(t)){let{message:f}=Q("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(f)}let{topic:i,request:n,chainId:s,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:a}=this.client.session.get(i);if(!Sl(a,s)){let{message:f}=Q("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(f)}if(!Iy(n)){let{message:f}=Q("MISSING_OR_INVALID",`request() ${JSON.stringify(n)}`);throw new Error(f)}if(!Ty(a,s,n.method)){let{message:f}=Q("MISSING_OR_INVALID",`request() method: ${n.method}`);throw new Error(f)}if(o&&!Ry(o,y0)){let{message:f}=Q("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${y0.min} and ${y0.max}`);throw new Error(f)}},this.isValidRespond=async t=>{var i;if(!Ot(t)){let{message:o}=Q("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}let{topic:n,response:s}=t;try{await this.isValidSessionTopic(n)}catch(o){throw(i=t?.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!Ay(s)){let{message:o}=Q("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(o)}},this.isValidPing=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidEmit=async t=>{if(!Ot(t)){let{message:a}=Q("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}let{topic:i,event:n,chainId:s}=t;await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!Sl(o,s)){let{message:a}=Q("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(a)}if(!My(n)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}if(!Py(o,s,n.name)){let{message:a}=Q("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(n)}`);throw new Error(a)}},this.isValidDisconnect=async t=>{if(!Ot(t)){let{message:n}=Q("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(n)}let{topic:i}=t;await this.isValidSessionOrPairingTopic(i)},this.isValidAuthenticate=t=>{let{chains:i,uri:n,domain:s,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!et(n,!1))throw new Error("uri is required parameter");if(!et(s,!1))throw new Error("domain is required parameter");if(!et(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(f=>ya(f).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:a}=ya(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async t=>{let{attestationId:i,hash:n,encryptedId:s,metadata:o,transportType:a}=t,f={verified:{verifyUrl:o.verifyUrl||po,validation:"UNKNOWN",origin:o.url||""}};try{if(a===We.link_mode){let g=this.getAppLinkIfEnabled(o,a);return f.verified.validation=g&&new URL(g).origin===new URL(o.url).origin?"VALID":"INVALID",f}let u=await this.client.core.verify.resolve({attestationId:i,hash:n,encryptedId:s,verifyUrl:o.verifyUrl});u&&(f.verified.origin=u.origin,f.verified.isScam=u.isScam,f.verified.validation=u.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.warn(u)}return this.client.logger.debug(`Verify context: ${JSON.stringify(f)}`),f},this.validateSessionProps=(t,i)=>{Object.values(t).forEach(n=>{if(!et(n,!1)){let{message:s}=Q("MISSING_OR_INVALID",`${i} must be in Record format. Received: ${JSON.stringify(n)}`);throw new Error(s)}})},this.getPendingAuthRequest=t=>{let i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0},this.addToRecentlyDeleted=(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let n=0,s=this.recentlyDeletedLimit/2;for(let o of this.recentlyDeletedMap.keys()){if(n++>=s)break;this.recentlyDeletedMap.delete(o)}}},this.checkRecentlyDeleted=t=>{let i=this.recentlyDeletedMap.get(t);if(i){let{message:n}=Q("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(n)}},this.isLinkModeEnabled=(t,i)=>{var n,s,o,a,f,u,g,y,S;return!t||i!==We.link_mode?!1:((s=(n=this.client.metadata)==null?void 0:n.redirect)==null?void 0:s.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((u=(f=this.client.metadata)==null?void 0:f.redirect)==null?void 0:u.universal)!==""&&((g=t?.redirect)==null?void 0:g.universal)!==void 0&&((y=t?.redirect)==null?void 0:y.universal)!==""&&((S=t?.redirect)==null?void 0:S.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"},this.getAppLinkIfEnabled=(t,i)=>{var n;return this.isLinkModeEnabled(t,i)?(n=t?.redirect)==null?void 0:n.universal:void 0},this.handleLinkModeMessage=({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;let i=cl(t,"topic")||"",n=decodeURIComponent(cl(t,"wc_ev")||""),s=this.client.session.keys.includes(i);s&&this.client.session.update(i,{transportType:We.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:n,sessionExists:s})},this.registerLinkModeListeners=async()=>{var t;if(_a()||ts()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){let i=global==null?void 0:global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);let n=await i.getInitialURL();n&&setTimeout(()=>{this.handleLinkModeMessage({url:n})},50)}}}}isInitialized(){if(!this.initialized){let{message:e}=Q("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ut.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:n,transportType:s}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(lu)?this.client.auth.authKeys.get(lu):{responseTopic:void 0,publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:s===We.link_mode?ro:pi});try{fo(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:n,transportType:s,encryptedId:Nr(i)})):hn(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:s}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:s})}catch(f){this.client.logger.error(f)}}registerExpirerEvents(){this.client.core.expirer.on(Qt.expired,async e=>{let{topic:t,id:i}=qf(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,Q("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,Q("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(pn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(pn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(li(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=Q("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!et(e,!1)){let{message:t}=Q("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(li(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=Q("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=Q("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(et(e,!1)){let{message:t}=Q("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{let{message:t}=Q("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!Ey(e)){let{message:t}=Q("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=Q("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(li(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=Q("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},x0=class extends wi{constructor(e,t){super(e,t,bM,T0),this.core=e,this.logger=t}},_0=class extends wi{constructor(e,t){super(e,t,yM,T0),this.core=e,this.logger=t}},E0=class extends wi{constructor(e,t){super(e,t,xM,T0,i=>i.id),this.core=e,this.logger=t}},S0=class extends wi{constructor(e,t){super(e,t,IM,mu,()=>lu),this.core=e,this.logger=t}},I0=class extends wi{constructor(e,t){super(e,t,AM,mu),this.core=e,this.logger=t}},A0=class extends wi{constructor(e,t){super(e,t,MM,mu,i=>i.id),this.core=e,this.logger=t}},M0=class{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new S0(this.core,this.logger),this.pairingTopics=new I0(this.core,this.logger),this.requests=new A0(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}},pu=class r extends qc{constructor(e){super(e),this.protocol=x2,this.version=_2,this.name=v0.name,this.events=new gu.EventEmitter,this.on=(i,n)=>this.events.on(i,n),this.once=(i,n)=>this.events.once(i,n),this.off=(i,n)=>this.events.off(i,n),this.removeListener=(i,n)=>this.events.removeListener(i,n),this.removeAllListeners=i=>this.events.removeAllListeners(i),this.connect=async i=>{try{return await this.engine.connect(i)}catch(n){throw this.logger.error(n.message),n}},this.pair=async i=>{try{return await this.engine.pair(i)}catch(n){throw this.logger.error(n.message),n}},this.approve=async i=>{try{return await this.engine.approve(i)}catch(n){throw this.logger.error(n.message),n}},this.reject=async i=>{try{return await this.engine.reject(i)}catch(n){throw this.logger.error(n.message),n}},this.update=async i=>{try{return await this.engine.update(i)}catch(n){throw this.logger.error(n.message),n}},this.extend=async i=>{try{return await this.engine.extend(i)}catch(n){throw this.logger.error(n.message),n}},this.request=async i=>{try{return await this.engine.request(i)}catch(n){throw this.logger.error(n.message),n}},this.respond=async i=>{try{return await this.engine.respond(i)}catch(n){throw this.logger.error(n.message),n}},this.ping=async i=>{try{return await this.engine.ping(i)}catch(n){throw this.logger.error(n.message),n}},this.emit=async i=>{try{return await this.engine.emit(i)}catch(n){throw this.logger.error(n.message),n}},this.disconnect=async i=>{try{return await this.engine.disconnect(i)}catch(n){throw this.logger.error(n.message),n}},this.find=i=>{try{return this.engine.find(i)}catch(n){throw this.logger.error(n.message),n}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}},this.authenticate=async(i,n)=>{try{return await this.engine.authenticate(i,n)}catch(s){throw this.logger.error(s.message),s}},this.formatAuthMessage=i=>{try{return this.engine.formatAuthMessage(i)}catch(n){throw this.logger.error(n.message),n}},this.approveSessionAuthenticate=async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.rejectSessionAuthenticate=async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(n){throw this.logger.error(n.message),n}},this.name=e?.name||v0.name,this.metadata=e?.metadata||to(),this.signConfig=e?.signConfig;let t=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:(0,jo.default)(Vo({level:e?.logger||v0.logger}));this.core=e?.core||new b2(e),this.logger=wt(t,this.name),this.session=new _0(this.core,this.logger),this.proposal=new x0(this.core,this.logger),this.pendingRequest=new E0(this.core,this.logger),this.engine=new w0(this),this.auth=new M0(this.core,this.logger)}static async init(e){let t=new r(e);return await t.initialize(),t}get context(){return Mt(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};function P0(r,e){let t=[...Sp,...e?.methods??[]];e?.methods?.includes("mvx_signLoginToken")||t.push("mvx_signLoginToken");let i=[`${wr}:${r}`],n=e?.events??[];return{requiredNamespaces:{[wr]:{methods:t,chains:i,events:n}}}}function R0(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=e.find(P0(r)).filter(i=>i.acknowledged);if(t.length>0){let i=t.length-1;return t[i]}if(e.session.length>0){let i=e.session.keys.length-1;return e.session.get(e.session.keys[i])}throw console.log("WalletConnect Session is not connected"),new Error("WalletConnect Session is not connected")}function ki(r,e){if(!e)throw new Error("WalletConnect is not initialized");let t=R0(r,e);if(!t?.topic)throw new Error("WalletConnect Session is not connected");return t.topic}function S2(r){return!!r}function N0(r){let e=r.namespaces[wr];if(e&&e.accounts){let t=e.accounts[0],[,,i]=t.split(":");return i}return""}function D0({transaction:r,response:e}){if(!e)throw console.log("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");let{signature:t,guardianSignature:i,version:n,options:s,guardian:o}=e,a=r.guardian;if(a&&a!==o)throw console.log("WalletConnect: Invalid Guardian"),new Error("WalletConnect: Invalid Guardian");return o&&(r.guardian=o),n&&(r.version=n),s!=null&&(r.options=s),r.signature=or(t),i&&(r.guardianSignature=or(i)),r}function I2(r){if(r)return{...r,url:to().url}}async function A2(r){return await new Promise(e=>setTimeout(()=>{e()},r))}var Zt=class{constructor(e,t,i,n,s){this.chainId="";this.isInitializing=!1;this.processingTopic="";this.options={};this.account={address:""};this.onClientConnect=e,this.chainId=t,this.walletConnectV2Relay=i,this.walletConnectV2ProjectId=n,this.options=s}disconnect(){this.account={address:"",signature:""},this.walletConnector=void 0,this.session=void 0,this.pairings=void 0}async init(){if(this.isInitialized())return this.isInitialized();try{if(!this.isInitializing){this.isInitializing=!0,this.disconnect();let e=this.options?.metadata?{metadata:I2(this.options?.metadata)}:{},t=await pu.init({...this.options,relayUrl:this.walletConnectV2Relay,projectId:this.walletConnectV2ProjectId,...e});this.walletConnector=t,this.isInitializing=!1,await this.subscribeToEvents(t),await this.checkPersistedState(t)}}catch{throw new Error("WalletConnect is unable to init")}finally{return this.isInitializing=!1,this.isInitialized()}}isInitialized(){return!!this.walletConnector&&!this.isInitializing}isConnected(){return!!(this.isInitialized()&&typeof this.session<"u")}getAccount(){return this.account}setAccount(e){this.account=e}async connect(e){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");let t=P0(this.chainId,e);try{return await this.walletConnector.connect({pairingTopic:e?.topic,...t})}catch{if(e?.topic)try{this.walletConnector.core?.expirer?.set(e.topic,0)}catch{console.error("WalletConnect: Unable to handle cleanup")}throw this.disconnect(),console.error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect"),new Error(e?.topic?"WalletConnect is unable to connect to existing pairing":"WalletConnect is unable to connect")}}async login(e){if(this.isInitializing=!0,typeof this.walletConnector>"u"&&await this.connect(),typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");typeof this.session<"u"&&await this.logout({topic:this.session?.topic});try{if(e&&e.approval){let t=await e.approval();if(e.token){await A2(Ep);let i=N0(t),s=t.namespaces[wr].methods.includes("mvx_signNativeAuthToken")?"mvx_signNativeAuthToken":"mvx_signLoginToken",{signature:o}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:t.topic,request:{method:s,params:{token:e.token,address:i}}});if(!o)throw console.error("WalletConnect could not sign login token"),new Error("WalletConnect could not sign login token");return await this.onSessionConnected({session:t,signature:o})}return await this.onSessionConnected({session:t,signature:""})}}catch{throw this.disconnect(),console.error("WalletConnect is unable to login"),new Error("WalletConnect is unable to login")}finally{this.isInitializing=!1}return null}async logout(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");try{if(this.processingTopic===(e?.topic||ki(this.chainId,this.walletConnector)))return!0;if(e?.topic)this.processingTopic=e.topic,await this.walletConnector.disconnect({topic:e.topic,reason:ke("USER_DISCONNECTED")});else{let t=ki(this.chainId,this.walletConnector);this.processingTopic=t,await this.walletConnector.disconnect({topic:t,reason:ke("USER_DISCONNECTED")}),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0})}}catch{console.error("WalletConnect: Already logged out")}finally{this.processingTopic=""}return!0}getAddress(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.address}getSignature(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.account.signature}async getPairings(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");return this.walletConnector?.core?.pairing?.pairings?.getAll({active:!0})??[]}async signMessage(e){let t=new Gt({data:Buffer.from(e.data),address:e.address??this.account.address,signer:"wallet-connect-v2",version:e.version});if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");try{let i=this.getAddress(),{signature:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{method:"mvx_signMessage",params:{address:i,message:t.data.toString()}}});if(!n)throw console.error("WalletConnect could not sign the message: invalid message response"),new Error("WalletConnect could not sign the message: invalid message response");try{t.signature=Buffer.from(n,"hex")}catch{throw console.error("WalletConnect: Invalid message signature"),new Error("WalletConnect: Invalid message signature")}}catch{throw new Error("WalletConnect could not sign the message")}return t}async signTransaction(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=yt.transactionToPlainObject(e);if(this.chainId!==e.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");try{let i=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{method:"mvx_signTransaction",params:{transaction:t}}});return D0({transaction:e,response:i})}catch{throw new Error("Transaction canceled")}}async signTransactions(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");let t=e.map(i=>{if(this.chainId!==i.chainID)throw console.error("WalletConnect: Request Chain Id different than Connection Chain Id"),new Error("WalletConnect: Request Chain Id different than Connection Chain Id");return yt.transactionToPlainObject(i)});try{let{signatures:i}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{method:"mvx_signTransactions",params:{transactions:t}}});if(!i)throw console.error("WalletConnect could not sign the transactions. Invalid signatures"),new Error("WalletConnect could not sign the transactions. Invalid signatures");if(!Array.isArray(i)||e.length!==i.length)throw new Error("WalletConnect could not sign the transactions. Invalid signatures");for(let[n,s]of e.entries()){let o=i[n];D0({transaction:s,response:o})}return e}catch{throw new Error("Transaction canceled")}}async sendCustomRequest(e){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");if(typeof this.session>"u")throw console.error("WalletConnect Session is not connected"),this.onClientConnect.onClientLogout(),new Error("WalletConnect Session is not connected");if(e?.request?.method){try{let t={...e.request},{method:i}=t,{response:n}=await this.walletConnector.request({chainId:`${wr}:${this.chainId}`,topic:ki(this.chainId,this.walletConnector),request:{...t,method:i}});n||console.error("WalletConnect could not send the custom request")}catch{console.error("WalletConnect could not send the custom request")}return}}async ping(){if(typeof this.walletConnector>"u")throw console.error("WalletConnect is not initialized"),new Error("WalletConnect is not initialized");typeof this.session>"u"&&console.error("WalletConnect Session is not connected");try{let e=ki(this.chainId,this.walletConnector);return await this.walletConnector.ping({topic:e}),!0}catch{return console.error("WalletConnect Ping Failed"),!1}}async loginAccount(e){return e?S2(e.address)?(this.account.address=e.address,e.signature&&(this.account.signature=e.signature),this.onClientConnect.onClientLogin(),this.account.address):(console.error(`WalletConnect: Invalid address ${e.address}`),this.walletConnector&&await this.logout(),""):""}async onSessionConnected(e){if(!e)return null;this.session=e.session,this.account.signature=e.signature||"";let t=N0(e.session);return t?(await this.loginAccount({address:t,signature:e.signature}),this.account.address=t,this.account):null}async handleTopicUpdateEvent({topic:e}){if(typeof this.walletConnector>"u"){console.error("WalletConnect is not initialized");return}try{let t=await this.getPairings();this.account.address&&!this.isInitializing&&t&&(t?.length===0?this.onClientConnect.onClientLogout():t[t.length-1]?.topic===e&&this.onClientConnect.onClientLogout())}catch{console.error("WalletConnect: Unable to handle topic update")}finally{this.pairings=await this.getPairings()}}async handleSessionEvents({topic:e,params:t}){if(typeof this.walletConnector>"u")throw new Error("WalletConnect is not initialized");if(this.session&&this.session?.topic!==e)return;let{event:i}=t;if(i?.name&&ki(this.chainId,this.walletConnector)===e){let n=i.data;this.onClientConnect.onClientEvent(n)}}async subscribeToEvents(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");try{e.on("session_update",({topic:t,params:i})=>{if(!this.session||this.session?.topic!==t)return;let{namespaces:n}=i,o={...e.session.get(t),namespaces:n};this.onSessionConnected({session:o})}),e.on("session_event",this.handleSessionEvents.bind(this)),e.on("session_delete",async({topic:t})=>{this.isInitializing&&(this.onClientConnect.onClientLogout(),this.disconnect()),!(!this.session||this.session?.topic!==t)&&(console.error("WalletConnect Session Deleted"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.on("session_expire",async({topic:t})=>{!this.session||this.session?.topic!==t||(console.error("WalletConnect Session Expired"),this.onClientConnect.onClientLogout(),this.disconnect(),await this.cleanupPendingPairings({deletePairings:!0}))}),e.core?.pairing?.events.on("pairing_delete",this.handleTopicUpdateEvent.bind(this)),e.core?.pairing?.events.on("pairing_expire",this.handleTopicUpdateEvent.bind(this))}catch{console.error("WalletConnect: Unable to handle events")}}async checkPersistedState(e){if(typeof e>"u")throw new Error("WalletConnect is not initialized");if(this.pairings=await this.getPairings(),!(typeof this.session<"u")&&e.session.length&&!this.account.address&&!this.isInitializing){let t=R0(this.chainId,e);if(t)return await this.onSessionConnected({session:t}),t}}async cleanupPendingPairings(e={}){if(!(typeof this.walletConnector>"u"))try{let t=this.walletConnector.core?.pairing?.pairings?.getAll({active:!1});if(!an(t))return;for(let i of t)if(e.deletePairings)this.walletConnector.core?.expirer?.set(i.topic,0);else try{await this.walletConnector.core?.relayer?.subscriber?.unsubscribe(i.topic)}catch{console.error("WalletConnect: Unable to handle cleanup")}}catch{console.error("WalletConnect: Unable to handle cleanup")}}};var C0=class{constructor(e){this.nonce=0;this.value="";this.receiver="";this.sender="";this.gasPrice=0;this.gasLimit=0;this.data="";this.chainID="";this.version=0;this.signature="";Object.assign(this,e)}},er=class r{constructor(e){this.walletUrl=e}async login(e){let t=this.buildWalletUrl({endpoint:vp,callbackUrl:e?.callbackUrl,params:{token:e?.token}});return await this.redirect(t,e?.redirectDelayMilliseconds),t}async redirect(e,t){t?await this.redirectLater(e,t):this.redirectImmediately(e)}redirectImmediately(e){window.location.href=e}async redirectLater(e,t){await new Promise(i=>{setTimeout(()=>{window.location.href=e,i(!0)},t)})}async logout(e){let t=this.buildWalletUrl({endpoint:yp,callbackUrl:e?.callbackUrl});return await this.redirect(t,e?.redirectDelayMilliseconds),!0}async signMessage(e,t){let i=this.buildWalletUrl({endpoint:_p,callbackUrl:t?.callbackUrl,params:{message:ji(e.data)}});return await this.redirect(i),i}getMessageSignatureFromWalletUrl(){let e=window.location.search.slice(1);console.info("getMessageSignatureFromWalletUrl(), url:",e);let t=ju(e);if((t.status?.toString()||"")!=="signed")throw new sc;return t.signature?.toString()||""}async guardTransactions(e,t){this.redirectTransactionsToEndpoint(xp,e,t)}async signTransactions(e,t){this.redirectTransactionsToEndpoint(wp,e,t)}async signTransaction(e,t){await this.signTransactions([e],t)}getTransactionsFromWalletUrl(e=window.location.search){let t=ju(e.slice(1));return r.isTxSignReturnSuccess(t)?this.getTxSignReturnValue(t):[]}static isTxSignReturnSuccess(e){return Object.prototype.hasOwnProperty.call(e,Po)&&e[Po]===Za}getTxSignReturnValue(e){console.info("getTxSignReturnValue(), urlParams:",e);let t=["nonce","value","receiver","sender","gasPrice","gasLimit","chainID","version","signature"];for(let s of t)if(!e[s]||!Array.isArray(e[s]))throw new Do;let i=e.nonce.length;for(let s of t)if(e[s].length!==i)throw new Do;let n=[];for(let s=0;s{let a=r.prepareWalletTransaction(o);for(let f in a)Object.prototype.hasOwnProperty.call(a,f)&&!Object.prototype.hasOwnProperty.call(n,f)&&(n[f]=[]),n[f].push(a[f])});let s=this.buildWalletUrl({endpoint:e,callbackUrl:i?.callbackUrl,params:n});window.location.href=s}};var O0=class{constructor(){this.origin=typeof window<"u"&&typeof window.location<"u"?window.location.hostname:"";this.apiUrl="https://api.multiversx.com";this.expirySeconds=60*60*24}},bo=class{constructor(e){this.config=Object.assign(new O0,e)}getToken(e,t,i){let n=this.encodeValue(e),s=this.encodeValue(t);return`${n}.${s}.${i}`}async initialize(e={}){let t=await this.getCurrentBlockHash(),i=this.encodeValue(JSON.stringify(e));return`${this.encodeValue(this.config.origin)}.${t}.${this.config.expirySeconds}.${i}`}async getCurrentBlockHash(){return this.config.gatewayUrl?await this.getCurrentBlockHashWithGateway():await this.getCurrentBlockHashWithApi()}async getCurrentBlockHashWithGateway(){let e=await this.getCurrentRound(),t=`${this.config.gatewayUrl}/blocks/by-round/${e}`;return(await this.get(t)).data.data.blocks.filter(o=>o.shard===this.config.blockHashShard)[0].hash}async getCurrentRound(){if(!this.config.gatewayUrl)throw new Error("Gateway URL not set");if(!this.config.blockHashShard)throw new Error("Blockhash shard not set");let e=`${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`;return(await this.get(e)).data.data.status.erd_current_round}async getCurrentBlockHashWithApi(){let e=`${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`,t=await this.get(e);return t.hash!==void 0?t.hash:this.getCurrentBlockHashWithApiFallback()}async getCurrentBlockHashWithApiFallback(){let e=`${this.config.apiUrl}/blocks?size=1&fields=hash`;return this.config.blockHashShard!==void 0&&(e+=`&shard=${this.config.blockHashShard}`),(await this.get(e)).hash}encodeValue(e){return this.escape(Xa(e))}escape(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async get(e){try{let t=await fetch(e,{method:"GET",headers:this.config.extraRequestHeaders});if(!t.ok)throw new Error(`HTTP error! Status: ${t.status}`);return await t.json()}catch(t){throw console.error("There was a problem with the fetch operation:",t),t}}};var bu=(r,e)=>t=>{let i=t.data;try{i=Ku()&&typeof i=="string"?JSON.parse(i):i}catch{console.error("error parsing eventData",i)}let{type:n,payload:s}=i;!Ku()&&t.origin!=To()||!(r===n||n==="CANCEL_RESPONSE")||(typeof window<"u"&&window.removeEventListener?.("message",bu(r,e)),e({type:n,payload:s}))};var bn=class r{constructor(e){this.initialized=!1;this.account={address:""};this.resetState=e=>{typeof window<"u"&&window.addEventListener("message",bu("RESET_STATE_RESPONSE",t=>{t.type==="RESET_STATE_RESPONSE"&&(e?.(),setTimeout(()=>{this.finalizeResetState()},500))}))};this.init=async()=>(await this.sendPostMessage({type:"FINALIZE_HANDSHAKE_REQUEST",payload:void 0}),this.initialized=!0,this.initialized);this.login=async()=>{if(!this.initialized)throw new Error("Provider not initialized");let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});return e.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the login action"),await this.cancelAction(),null):e.payload.data?(this.account=e.payload.data,this.account):(console.error("Error logging in",e.payload.error??"No data received"),null)};this.logout=async()=>{let e=await this.sendPostMessage({type:"LOGOUT_REQUEST",payload:void 0});return this.initialized=!1,this.disconnect(),!!e.payload.data};this.relogin=async()=>{let e=await this.sendPostMessage({type:"LOGIN_REQUEST",payload:void 0});if(e.type=="CANCEL_RESPONSE")return console.warn("Cancelled the re-login action"),await this.cancelAction(),null;if(!e.payload.data)return console.error("Re-login Error",e.payload.error??"No data received"),null;let{data:t,error:i}=e.payload;if(i||!t)throw new Error("Unable to re-login");let{accessToken:n}=t;return n?(this.account=t,n):(console.error("Unable to re-login. Missing accessToken."),null)};this.signTransactions=async e=>{let t=await this.sendPostMessage({type:"SIGN_TRANSACTIONS_REQUEST",payload:e.map(s=>yt.transactionToPlainObject(s))}),{data:i,error:n}=t.payload;if(n||!i)throw new Error("Unable to sign transactions");if(t.type=="CANCEL_RESPONSE")throw this.cancelAction(),new Error("Cancelled the transactions signing action");return i.map(s=>yt.plainObjectToTransaction(s))};this.signTransaction=async e=>(await this.signTransactions([e]))[0];this.signMessage=async e=>{let t=await this.sendPostMessage({type:"SIGN_MESSAGE_REQUEST",payload:{message:ji(e.data)}}),{data:i,error:n}=t.payload;return n||!i?(console.error("Unable to sign message"),null):t.type=="CANCEL_RESPONSE"?(console.warn("Cancelled the message signing action"),this.cancelAction(),null):i.status!=="signed"?(console.error("Could not sign message"),null):new Gt({data:e.data,address:e.address??this.account.address,signer:"webview",version:e.version,signature:or(i.signature||"")})};this.cancelAction=async()=>this.sendPostMessage({type:"CANCEL_ACTION_REQUEST",payload:void 0});this.finalizeResetState=async()=>this.sendPostMessage({type:"FINALIZE_RESET_STATE_REQUEST",payload:void 0});this.sendPostMessage=async e=>{let t=window;return t&&(t.ReactNativeWebView?t.ReactNativeWebView.postMessage(JSON.stringify(e)):t.webkit?t.webkit.messageHandlers?.jsHandler?.postMessage(JSON.stringify(e),To()):t.parent&&t.parent.postMessage(e,To())),await this.waitingForResponse(Ip[e.type])};this.waitingForResponse=async e=>await new Promise(t=>{typeof window<"u"&&window.addEventListener?.("message",bu(e,t))});e?.resetStateCallback&&this.resetState(e.resetStateCallback)}static getInstance(e){return r._instance||(r._instance=new r(e)),r._instance}disconnect(){this.account={address:""}}isInitialized(){return this.initialized}isConnected(){return!!this.account.address}getAccount(){return this.account}setAccount(e){this.account=e}};var te=class{static set(e,t){if(!e)return;let i={...this.events,[e]:t};this.events=i}static get(e){if(!(!e||!this.events))return this.events[e]}static run(e,...t){!e||!this.events||this.events[e]?.(...t)}static clear(){this.events=void 0}};var M2=(U=>(U.onLoginStart="onLoginStart",U.onLoginSuccess="onLoginSuccess",U.onLoginFailure="onLoginFailure",U.onLogoutStart="onLogoutStart",U.onLogoutSuccess="onLogoutSuccess",U.onLogoutFailure="onLogoutFailure",U.onQrPending="onQrPending",U.onQrLoaded="onQrLoaded",U.onTxStart="onTxStart",U.onTxSent="onTxSent",U.onTxFinalized="onTxFinalized",U.onTxFailure="onTxFailure",U.onSignMsgStart="onSignMsgStart",U.onSignMsgFinalized="onSignMsgFinalized",U.onSignMsgFailure="onSignMsgFailure",U.onQueryStart="onQueryStart",U.onQueryFinalized="onQueryFinalized",U.onQueryFailure="onQueryFailure",U))(M2||{}),L0=(o=>(o.ledger="ledger",o.mobile="mobile",o.webWallet="web-wallet",o.browserExtension="browser-extension",o.xAlias="x-alias",o.webview="webview",o))(L0||{}),CM=(t=>(t.mvx_cancelAction="mvx_cancelAction",t.mvx_signNativeAuthToken="mvx_signNativeAuthToken",t))(CM||{}),OM=(e=>(e.hasWebWalletGuardianSign="hasWebWalletGuardianSign",e))(OM||{});var ot=r=>typeof r=="string"?r.toUpperCase():r instanceof Error?r.message:JSON.stringify(r);var vo=async r=>{if(!r.dappProvider)throw new Error("Logout failed: There is no active session!");te.run("onLogoutStart");try{let e=await r.dappProvider.logout();return e&&(re.clear(),te.run("onLogoutSuccess")),e}catch(e){let t=ot(e);console.warn(`Something went wrong trying to logout the user: ${t}`),te.run("onLogoutFailure",t)}};function vu(r){return r[Math.floor(Math.random()*r.length)]}var T2=async r=>{if(!r.initOptions.walletConnectV2ProjectId||!r.initOptions.chainType)return;let e={onClientLogin:()=>{},onClientLogout:()=>vo(r),onClientEvent:n=>{console.log("wc2 session event: ",n)}},t=vu(r.initOptions.walletConnectV2RelayAddresses),i=new Zt(e,At[r.initOptions.chainType].shortId,t,r.initOptions.walletConnectV2ProjectId);try{return await i.init(),i}catch{console.warn("Can't initialize the Dapp Provider!")}};var $t=r=>{if(typeof window<"u"){let e=new URL(window.location.href);return new URLSearchParams(e.search).get(r)}};var F0=async(r,e)=>{let t=$t("signature"),i=$t("address"),n=re.get("address"),s=re.get("loginToken");if(t&&re.set("signature",t),i||n){i&&(re.set("address",i),window.history.replaceState(null,"",window.location.pathname));let o=new er(`${r}${Vi}`);if(t&&e&&i){let f=new bo({apiUrl:e,origin:window.location.origin}).getToken(i,s,t);re.set("accessToken",f)}return o}};var yu=class r{constructor(e){this.status=(e||"").toLowerCase()}static createUnknown(){return new r("unknown")}isPending(){return this.status=="received"||this.status=="pending"}isExecuted(){return this.isSuccessful()||this.isFailed()||this.isInvalid()}isSuccessful(){return this.status=="executed"||this.status=="success"||this.status=="successful"}isFailed(){return this.status=="fail"||this.status=="failed"||this.status=="unsuccessful"||this.isInvalid()}isInvalid(){return this.status=="invalid"}toString(){return this.status}valueOf(){return this.status}equals(e){return e?this.status==e.status:!1}};var wu=class{constructor({apiUrl:e,chainType:t,apiTimeout:i}){this.chainType=t||ac,this.apiUrl=e||At[this.chainType]?.apiAddress,this.apiTimeout=i||At[this.chainType]?.apiTimeout}async apiGet(e,t){if(typeof fetch<"u"){let i=new AbortController,n=setTimeout(()=>i.abort(),this.apiTimeout),s={method:"GET",headers:{"Content-Type":"application/json",Accept:"application/json"},signal:i.signal};try{let o=await fetch(this.apiUrl+"/"+e,Object.assign(s,t||{})),a=await o.json();if(!o.ok){let f=a?.error||o.status;return clearTimeout(n),Promise.reject(f)}return clearTimeout(n),a}catch(o){this.handleApiError(o,e)}}}async apiPost(e,t,i){if(typeof fetch<"u"){let n=new AbortController,s=setTimeout(()=>n.abort(),this.apiTimeout),o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(t||{}),signal:n.signal};try{let a=await fetch(this.apiUrl+"/"+e,Object.assign(o,i||{})),f=await a.json();if(!a.ok){let u=f?.error||a.status;return clearTimeout(s),Promise.reject(u)}return clearTimeout(s),f}catch(a){this.handleApiError(a,e)}}}handleApiError(e,t){if(!e.response)throw new Error(`Request error on url [${t}]: [${e.toString()}]`);let i=e.response.data,n=i.error||i.message||JSON.stringify(i);throw new Error(n)}async sendTransaction(e){let t=yt.transactionToPlainObject(e);return await this.apiPost("transactions",t)}async getAccount(e){let t=await this.apiGet(`accounts/${e}`);return{address:t?.address||"",nonce:Number(t?.nonce||0),balance:t?.balance,code:t?.code||"",userName:t?.username||""}}async getGuardianData(e){let t=await this.apiGet(`address/${e}/guardian-data`);return{guarded:t?.data?.guardianData?.guarded||!1,activeGuardian:t?.data?.guardianData?.activeGuardian,pendingGuardian:t?.data?.guardianData?.pendingGuardian}}async getTransaction(e){let t=await this.apiGet(`transactions/${e}`),i=new yu(t.status);return{hash:e,type:t.type||"",nonce:t.nonce||0,round:t.round,epoch:t.epoch||0,value:(t.value||0).toString(),sender:t.sender,receiver:t.receiver,gasPrice:t.gasPrice||0,gasLimit:t.gasLimit||0,data:On(t.data||""),status:i,timestamp:t.timestamp||0,blockNonce:t.blockNonce||0,hyperblockNonce:t.hyperblockNonce||0,hyperblockHash:t.hyperblockHash||"",receipt:t.receipt,logs:t.logs,contractResults:t.results||[],isCompleted:!i.isPending()}}async queryContract({address:e,func:t,args:i,value:n,caller:s}){try{let o={scAddress:e,caller:s,funcName:t,value:n,args:()=>i?.map(f=>Xa(f))},a=await this.apiPost("query",o);return{returnData:a.returnData,returnCode:a.returnCode,returnMessage:a.returnMessage}}catch(o){this.handleApiError(o,"query")}}};var yo=()=>new Date().setHours(new Date().getHours()+24),xu=r=>Date.now()>r;var cs=async r=>{let e=re.get("address"),t=re.get("expires");if(!(t&&xu(t))&&e&&r.networkProvider){let n=new _i(e);try{let s=await r.networkProvider.getAccount(e),o=await r.networkProvider.getGuardianData(e);re.set("address",e),re.set("activeGuardian",o.guarded&&o.activeGuardian?.address?o.activeGuardian.address:""),re.set("nonce",s.nonce.valueOf()),re.set("balance",s.balance.toString()),n.update(s)}catch(s){let o=ot(s);console.warn(`Something went wrong trying to synchronize the user account: ${o}`)}}};var P2=async(r,e,t,i="/")=>{let n=await cc(),o={callbackUrl:encodeURIComponent(`${window.location.origin}${i}`),token:e};try{if(n&&!await n.login(o))throw new Error("There were problems while logging in!")}catch(u){let g=ot(u);throw new Error(g)}if(!n)throw new Error("There were problems with auth provider initialization!");let a=n.getAccount();re.set("loginToken",e);let f=a?.signature;if(f&&re.set("signature",f),r.networkProvider&&f)try{let u=await n.getAddress();if(!u)throw new Error("Canceled!");re.set("address",u),re.set("loginMethod","browser-extension"),re.set("expires",yo()),await cs(r);let g=t.getToken(u,e,f);return re.set("accessToken",g),te.run("onLoginSuccess"),n}catch(u){throw new Error(`Something went wrong trying to synchronize the user account: ${u?.message}`)}};var R3=Be(P3(),1);var TT=r=>{let e=document.createElement("template");return e.innerHTML=r.trim(),e.content.firstChild?.cloneNode(!0)},PT=r=>{let e=`${Mp}?wallet-connect=${encodeURIComponent(r)}`,t=document.createElement("a");return t.setAttribute("href",e),t.setAttribute("rel","noopener noreferrer nofollow"),t.setAttribute("target","_blank"),t.textContent="xPortal login",t.classList.add("elven-qr-code-deep-link"),t},RT=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairings"),r},NT=()=>{let r=document.createElement("div");return r.textContent="Existing WalletConnect pairings:",r.classList.add("elven-wc-pairings-header"),r},op={},DT=(r,e)=>{let t=document.createElement("button");return t.classList.add("elven-wc-pairings-remove-btn"),t.textContent="\u2716",op[r.topic]=new AbortController,t.addEventListener("click",i=>{i.stopImmediatePropagation(),e(r.topic)},{signal:op[r.topic].signal}),t},Cu={},CT=(r,e,t)=>{let i=document.createElement("div"),n=document.createElement("div");i.classList.add("elven-wc-pairing-item"),i.setAttribute("id",r.topic),n.classList.add("elven-wc-pairing-item-description"),n.textContent=`${r.peerMetadata?.description} (${r.peerMetadata?.url})`,i.appendChild(n);let s=DT(r,e);return i.appendChild(s),Cu[r.topic]=new AbortController,i.addEventListener("click",()=>t(r.topic),{signal:Cu[r.topic].signal}),i},OT=()=>{let r=document.createElement("div");return r.classList.add("elven-wc-pairing-item-confirm-msessage"),r.setAttribute("id","elven-wc-pairing-item-confirm-msessage"),r.innerText="Confirm on xPortal app!",r},LT=r=>{if(!r)return;document.getElementById(r)?.remove()},FT=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),UT=async r=>r?await(0,R3.toString)(r,{type:"svg"}):void 0,N3=async(r,e,t,i)=>{if(!r)throw new Error("Please provide the QR Code and WalletConnect Pairings container id!");let n=null;typeof r=="string"?n=document.getElementById(r):r instanceof HTMLElement&&(n=r);let s=await UT(e),o;if(s&&(o=TT(s)),n&&o&&(n.replaceChildren(),n.appendChild(o),FT()&&n.appendChild(PT(e))),n&&t instanceof Zt){let a=t.pairings,f=async g=>{try{g&&(await t.logout({topic:g}),LT(g))}catch(y){let S=ot(y);console.warn(`Something went wrong trying to remove the existing pairing: ${S}`)}finally{Cu[g].abort()}},u=async g=>{try{let{approval:y}=await t.connect({topic:g,methods:["mvx_cancelAction","mvx_signNativeAuthToken"]});document.getElementById("elven-wc-pairing-item-confirm-msessage")||document.getElementById(g)?.after(OT()),await t.login({approval:y,token:i})}catch(y){let S=ot(y);console.warn(`Something went wrong trying to login the user: ${S}`)}finally{for(let y of Object.values(Cu))y?.abort();for(let y of Object.values(op))y?.abort()}};if(a&&a.length>0){let g=RT();n.appendChild(g);let y=NT();g.appendChild(y);for(let S of a){let I=CT(S,f,u);g.appendChild(I)}}}return n};var D3=async(r,e,t,i)=>{if(!i)throw new Error("You haven't provided the QR code container DOM element id");let n=vu(r.initOptions.walletConnectV2RelayAddresses);if(!n||!r.networkProvider)throw new Error("Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!");if(!r.initOptions.walletConnectV2ProjectId)throw new Error("Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)");if(!r.initOptions.chainType)throw new Error("Please provide the chain type in ElvenJS.init function!");let s,o={onClientLogin:async()=>{if(r.dappProvider instanceof Zt){let f=await r.dappProvider.getAddress(),u=await r.dappProvider.getSignature();re.set("address",f),re.set("loginMethod","mobile"),re.set("expires",yo()),await cs(r),u&&re.set("signature",u),re.set("loginToken",e);let g=t.getToken(f,e,u);re.set("accessToken",g),te.run("onLoginSuccess"),s?.replaceChildren()}},onClientLogout:async()=>{r.dappProvider instanceof Zt&&await vo(r)},onClientEvent:f=>{console.log("wc2 session event: ",f)}},a=new Zt(o,At[r.initOptions.chainType].shortId,n,r.initOptions.walletConnectV2ProjectId);try{if(a){r.dappProvider=a,te.run("onQrPending"),await a.init();let{uri:f,approval:u}=await a.connect({methods:["mvx_cancelAction","mvx_signNativeAuthToken"]}),g=e?`${f}&token=${e}`:f;return i&&g&&(s=await N3(i,g,a,e),te.run("onQrLoaded")),await a.login({approval:u,token:e}),a}}catch(f){let u=ot(f);console.warn(`Something went wrong trying to login the user: ${u}`),te.run("onLoginFailure",u)}};var ap=async(r,e,t,i)=>{let n=new er(`${r}${Vi}`),o={callbackUrl:typeof window<"u"?encodeURIComponent(`${window.location.origin}${i||"/"}`):"/",token:e};try{return re.set("loginMethod",At[t].xAliasAddress===r?"x-alias":"web-wallet"),await n.login(o),re.set("expires",yo()),re.set("loginToken",e),n}catch(a){let f=ot(a);console.warn(`Something went wrong trying to login the user: ${f}`),re.set("loginMethod",""),te.run("onLoginFailure",f)}};var Ou=async(r,e)=>{te.run("onTxSent",r);let i=await new Co(e).awaitCompleted(r.txHash),n=i.sender,s=new _i(n),o=await e.getAccount(n);s.update(o),re.set("address",s.bech32()),re.set("balance",s.balance),te.run("onTxFinalized",i)};var Lu=r=>{let e=r.sender,t=new _i(e),i=r.nonce.valueOf();t.incrementNonce(),re.set("nonce",(i+1n).toString())};var C3=async(r,e,t,i)=>{if($t(Po)===Za&&r&&e){let s=re.get("activeGuardian"),o=re.get("loginMethod"),a=$t("hasWebWalletGuardianSign"),f;if("getTransactionsFromWalletUrl"in r){if(f=r.getTransactionsFromWalletUrl()?.[0],!f)return;o==="web-wallet"&&(f.data=Ki(f.data))}else s&&o!=="web-wallet"&&o!=="x-alias"&&a&&(f=new er(`${t}${Vi}`).getTransactionsFromWalletUrl()?.[0]);if(f){let u=yt.plainObjectToTransaction(f);u.nonce=BigInt(i),Lu(u);try{te.run("onTxStart",u);let g=await e.sendTransaction(u);await Ou(g,e)}catch(g){let S=`Getting transaction information failed! ${ot(g)}`;throw te.run("onTxFailure",u,S),new Error(S)}finally{window.history.replaceState(null,"",window.location.pathname)}}window.history.replaceState(null,"",window.location.pathname)}};var O3=r=>{let e=re.get("activeGuardian");return e&&(r.version=Qa,r.options=gp,r.guardian=e),r},L3=async(r,e)=>{let t=new er(`${e}${Vi}`),i=window?.location.href,n=new URL(i);n.searchParams.set("hasWebWalletGuardianSign","true"),await t.guardTransactions([r],{callbackUrl:encodeURIComponent(n.toString())})},F3=r=>{let e=re.get("activeGuardian");return!(!re.get("address")||!e||r.isGuardedTransaction())};var U3=()=>{let r=!$t("walletProviderStatus"),e=$t("status")==="signed",t=$t("message"),i=$t("signature");r&&e&&t&&i&&(te.run("onSignMsgFinalized",t,i),window.history.replaceState(null,"",window.location.pathname))};function qT(r){try{let e=atob(r),t=btoa(e),i=Mo(r),n=Ki(i),s=r===t||t.startsWith(r),o=r===n||n.startsWith(r);if(s&&o)return!0}catch{return!1}return!1}function Io(r){return qT(r)?atob(r):r}var Fu=r=>Object.prototype.toString.call(r)==="[object String]";var q3=r=>{if(!r||!Fu(r))return null;let e=r.split(".");if(e.length!==4)return null;try{let[t,i,n,s]=e,o=JSON.parse(Io(s)),a=Io(t);return{ttl:Number(n),extraInfo:o,origin:a,blockHash:i}}catch(t){return console.error(`Error trying to decode ${r}:`,t),null}};var B3=r=>{if(!r||!Fu(r))return null;let e=r.split(".");if(e.length!==3)return console.error("Invalid nativeAuthToken. You may be trying to decode a loginToken. Try using decodeLoginToken method instead"),null;try{let[t,i,n]=e,s=Io(t),o=Io(i),a=q3(o);if(!a)return{address:s,body:o,signature:n,blockHash:"",origin:"",ttl:0};let f={...a,address:s,body:o,signature:n};return a.extraInfo?.timestamp||delete f.extraInfo,f}catch{return null}};function k3(r,e){let t=B3(r);if(t==null)return;let{signature:i,address:n,body:s}=t;i&&r&&n&&(re.set("loginToken",s),re.set("accessToken",r),re.set("signature",i),re.set("address",n),re.set("loginMethod","webview"),e.dappProvider=new bn)}var z3=r=>{r.onLoginStart&&te.set("onLoginStart",r.onLoginStart),r.onLoginSuccess&&te.set("onLoginSuccess",r.onLoginSuccess),r.onLoginFailure&&te.set("onLoginFailure",r.onLoginFailure),r.onLogoutStart&&te.set("onLogoutStart",r.onLogoutStart),r.onLogoutSuccess&&te.set("onLogoutSuccess",r.onLogoutSuccess),r.onLogoutFailure&&te.set("onLogoutFailure",r.onLogoutFailure),r.onQrPending&&te.set("onQrPending",r.onQrPending),r.onQrLoaded&&te.set("onQrLoaded",r.onQrLoaded),r.onTxStart&&te.set("onTxStart",r.onTxStart),r.onTxSent&&te.set("onTxSent",r.onTxSent),r.onTxFinalized&&te.set("onTxFinalized",r.onTxFinalized),r.onTxFailure&&te.set("onTxFailure",r.onTxFailure),r.onSignMsgStart&&te.set("onSignMsgStart",r.onSignMsgStart),r.onSignMsgFinalized&&te.set("onSignMsgFinalized",r.onSignMsgFinalized),r.onSignMsgFailure&&te.set("onSignMsgFailure",r.onSignMsgFailure),r.onQueryStart&&te.set("onQueryStart",r.onQueryStart),r.onQueryFinalized&&te.set("onQueryFinalized",r.onQueryFinalized),r.onQueryFailure&&te.set("onQueryFailure",r.onQueryFailure)};var Uu=async r=>{te.run("onLoginStart");try{await r(()=>{te.run("onLoginSuccess")})}catch(e){let t=ot(e);console.warn(`Something went wrong trying to login the user: ${t}`),te.run("onLoginFailure",t)}};var cp=class{static async init(e){let t=re.get();if(t.expires&&xu(t.expires)){re.clear(),this.dappProvider=void 0;return}this.initOptions={chainType:ac,apiUrl:Ap,apiTimeout:1e4,walletConnectV2ProjectId:"",walletConnectV2RelayAddresses:Tp,...e},this.networkProvider=new wu(this.initOptions),z3(this.initOptions);let i=$t("accessToken");i&&await Uu(async s=>{k3(i,this),await cs(this),s()}),(t?.address||(t.loginMethod==="web-wallet"||t.loginMethod==="x-alias")&&$t("address"))&&t?.loginMethod&&(await Uu(async s=>{t.loginMethod==="browser-extension"&&(this.dappProvider=await cc()),t.loginMethod==="mobile"&&(this.dappProvider=await T2(this)),t.loginMethod==="webview"&&(this.dappProvider=new bn),t.loginMethod==="web-wallet"&&this.initOptions?.chainType&&(this.dappProvider=await F0(At[this.initOptions.chainType].walletAddress,this.initOptions.apiUrl)),t.loginMethod==="x-alias"&&this.initOptions?.chainType&&(this.dappProvider=await F0(At[this.initOptions.chainType].xAliasAddress,this.initOptions.apiUrl)),await cs(this),s()}),this.initOptions?.chainType&&(await C3(this.dappProvider,this.networkProvider,At[this.initOptions.chainType][t.loginMethod==="x-alias"?"xAliasAddress":"walletAddress"],t.nonce),U3()))}static async login(e,t){if(!Object.values(L0).includes(e)){let n="Wrong login method!";throw te.run("onLoginFailure",n),new Error(n)}if(!this.networkProvider){let n="Login failed: Use ElvenJs.init() first!";throw te.run("onLoginFailure",n),new Error(n)}await Uu(async()=>{let n=new bo({apiUrl:this.initOptions?.apiUrl,origin:window.location.origin}),s=await n.initialize();if(e==="browser-extension"){let o=await P2(this,s,n,t?.callbackRoute);this.dappProvider=o}if(e==="mobile"){let o=await D3(this,s,n,t?.qrCodeContainer);this.dappProvider=o}if(e==="web-wallet"&&this.initOptions?.chainType){let o=await ap(At[this.initOptions.chainType].walletAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}if(e==="x-alias"&&this.initOptions?.chainType){let o=await ap(At[this.initOptions.chainType].xAliasAddress,s,this.initOptions?.chainType,t?.callbackRoute);this.dappProvider=o}})}static async logout(){try{let e=await vo(this);return this.dappProvider=void 0,e}catch(e){let t=ot(e);console.warn("Something went wrong when logging out: ",t)}}static async signAndSendTransaction(e){if(!this.dappProvider){let i="Transaction signing failed: There is no active session!";throw te.run("onTxFailure",e,i),new Error(i)}if(!this.networkProvider){let i="Transaction signing failed: There is no active network provider!";throw te.run("onTxFailure",e,i),new Error(i)}let t=O3(e);try{te.run("onTxStart",e);let i=re.get();if(e.nonce=i.nonce,this.dappProvider instanceof Ln&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof Zt&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof bn&&(t=await this.dappProvider.signTransaction(e)),this.dappProvider instanceof er&&await this.dappProvider.signTransaction(e),i.loginMethod!=="web-wallet"&&i.loginMethod!=="x-alias"){let n=F3(t);if(n||Lu(t),n&&this.initOptions?.chainType){await L3(t,At[this.initOptions.chainType].walletAddress);return}let s=await this.networkProvider.sendTransaction(t);await Ou(s,this.networkProvider)}}catch(i){let n=ot(i);throw te.run("onTxFailure",t,`Getting transaction information failed! ${n}`),new Error(`Getting transaction information failed! ${n}`)}return t}static async signMessage(e,t){if(!this.dappProvider){let n="Message signing failed: There is no active session!";throw te.run("onSignMsgFailure",e,n),new Error(n)}if(!this.networkProvider){let n="Message signing failed: There is no active network provider!";throw te.run("onSignMsgFailure",e,n),new Error(n)}let i="";try{if(te.run("onSignMsgStart",e),this.dappProvider instanceof Ln){let s=await this.dappProvider.signMessage(new Gt({data:Cn(e)}));s?.signature&&(i=yr(s.signature))}if(this.dappProvider instanceof Zt){let s=await this.dappProvider.signMessage(new Gt({data:Cn(e)}));s?.signature&&(i=yr(s.signature))}if(this.dappProvider instanceof bn){let s=await this.dappProvider.signMessage(new Gt({data:Cn(e)}));s?.signature&&(i=yr(s.signature))}if(this.dappProvider instanceof er){let s=a=>encodeURIComponent(a).replace(/[!'()*]/g,f=>`%${f.charCodeAt(0).toString(16).toUpperCase()}`),o=t?.callbackUrl||window.location.origin;await this.dappProvider.signMessage(new Gt({data:Cn(e)}),{callbackUrl:encodeURIComponent(`${o}${o.includes("?")?"&":"?"}message=${s(e)}`)})}let n=re.get();return n.loginMethod!=="web-wallet"&&n.loginMethod!=="x-alias"&&te.run("onSignMsgFinalized",e,i),{message:e,messageSignature:i}}catch(n){let s=ot(n);throw te.run("onSignMsgFailure",e,s),new Error(`Message signing failed! ${s}`)}}static async queryContract({address:e,func:t,args:i=[],value:n=0,caller:s}){if(!this.networkProvider)throw new Error("Query failed: There is no active network provider!");if(!e||!t)throw new Error("Query failed: The Query arguments are not valid! Address and func required");let o={address:e,func:t,args:i,value:n,caller:s};try{te.run("onQueryStart",o);let a=await this.networkProvider.queryContract(o);return te.run("onQueryFinalized",a),a}catch(a){let f=ot(a);throw te.run("onQueryFinalized",o,f),new Error(`Smart contract query failed! ${f}`)}}static{this.storage=re}static{this.destroy=()=>{this.networkProvider=void 0,this.dappProvider=void 0,this.initOptions=void 0,te.clear()}}};var BT=({amount:r,decimals:e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let t=r.toString().replace(/,/g,""),[i,n=""]=t.split("."),s=i+n.padEnd(e,"0");return s=s.substring(0,i.length+e),BigInt(s)},j3=({amount:r,decimals:e,rounding:t=e})=>{if(e<0)throw new Error("Decimal places shouldn't be negative number!");let i=BigInt(r)<0n,n=BigInt(r).toString();i&&(n=n.slice(1)),n=n.padStart(e+1,"0");let s=n.slice(0,-e),o=n.slice(-e);if(t=5){let u=BigInt("1"+"0".repeat(e-t)),g=BigInt(r)+u;return i&&(g=-g),j3({amount:g,decimals:e,rounding:t})}}let a=`${s}.${o.padEnd(t,"0")}`;return a=a.replace(/\.?0+$/,""),i&&(a=`-${a}`),a};export{_i as Account,CM as DappCoreWCV2CustomMethodsEnum,cp as ElvenJS,M2 as EventStoreEvents,L0 as LoginMethodsEnum,Ro as Transaction,Co as TransactionWatcher,OM as WebWalletUrlParamsEnum,j3 as formatAmount,BT as parseAmount}; -/*! Bundled license information: - -tslib/tslib.es6.js: - (*! ***************************************************************************** - Copyright (c) Microsoft Corporation. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH - REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, - INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - PERFORMANCE OF THIS SOFTWARE. - ***************************************************************************** *) - -js-sha3/src/sha3.js: - (** - * [js-sha3]{@link https://github.com/emn178/js-sha3} - * - * @version 0.8.0 - * @author Chen, Yi-Cyuan [emn178@gmail.com] - * @copyright Chen, Yi-Cyuan 2015-2018 - * @license MIT - *) -*/ diff --git a/package-lock.json b/package-lock.json index ef76c3f..97e4642 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,33 +1,389 @@ { - "name": "elven.js", - "version": "1.0.0", + "name": "elven.js-monorepo", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "elven.js", - "version": "1.0.0", - "license": "MIT", + "name": "elven.js-monorepo", + "workspaces": [ + "packages/*", + "configs/*" + ], "devDependencies": { - "@eslint/eslintrc": "3.1.0", - "@eslint/js": "9.14.0", - "@types/qrcode": "1.5.5", - "@types/serve-handler": "6.1.4", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", - "@walletconnect/sign-client": "^2.17.1", - "esbuild": "0.24.0", - "eslint": "9.14.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.2.1", - "globals": "15.11.0", + "@configs/esbuild": "workspace:*", + "@configs/eslint-config": "workspace:*", + "@configs/tsconfig": "workspace:*", + "@types/node": "22.9.0", + "eslint": "9.15.0", "prettier": "3.3.3", - "qrcode": "1.5.4", "rimraf": "6.0.1", "serve-handler": "6.1.6", + "turbo": "2.3.0", "typescript": "5.6.3" } }, + "configs/esbuild": { + "name": "@configs/esbuild", + "devDependencies": { + "esbuild": "0.24.0" + } + }, + "configs/eslint-config": { + "name": "@configs/eslint-config", + "version": "0.0.0", + "devDependencies": { + "@eslint/eslintrc": "3.2.0", + "@eslint/js": "9.15.0", + "@typescript-eslint/eslint-plugin": "8.14.0", + "@typescript-eslint/parser": "8.14.0", + "eslint-config-prettier": "9.1.0", + "eslint-plugin-prettier": "5.2.1" + } + }, + "configs/eslint-config/node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "configs/eslint-config/node_modules/@eslint/js": { + "version": "9.14.0", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "configs/eslint-config/node_modules/@pkgr/core": { + "version": "0.1.1", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/eslint-plugin": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/regexpp": "^4.10.0", + "@typescript-eslint/scope-manager": "8.12.2", + "@typescript-eslint/type-utils": "8.12.2", + "@typescript-eslint/utils": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2", + "graphemer": "^1.4.0", + "ignore": "^5.3.1", + "natural-compare": "^1.4.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/parser": { + "version": "8.12.2", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/scope-manager": "8.12.2", + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/typescript-estree": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2", + "debug": "^4.3.4" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/scope-manager": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/type-utils": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/typescript-estree": "8.12.2", + "@typescript-eslint/utils": "8.12.2", + "debug": "^4.3.4", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/types": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/typescript-estree": { + "version": "8.12.2", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/visitor-keys": "8.12.2", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/utils": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.12.2", + "@typescript-eslint/types": "8.12.2", + "@typescript-eslint/typescript-estree": "8.12.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "configs/eslint-config/node_modules/@typescript-eslint/visitor-keys": { + "version": "8.12.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.12.2", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "configs/eslint-config/node_modules/eslint-config-prettier": { + "version": "9.1.0", + "dev": true, + "license": "MIT", + "bin": { + "eslint-config-prettier": "bin/cli.js" + }, + "peerDependencies": { + "eslint": ">=7.0.0" + } + }, + "configs/eslint-config/node_modules/eslint-plugin-prettier": { + "version": "5.2.1", + "dev": true, + "license": "MIT", + "dependencies": { + "prettier-linter-helpers": "^1.0.0", + "synckit": "^0.9.1" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint-plugin-prettier" + }, + "peerDependencies": { + "@types/eslint": ">=8.0.0", + "eslint": ">=8.0.0", + "eslint-config-prettier": "*", + "prettier": ">=3.0.0" + }, + "peerDependenciesMeta": { + "@types/eslint": { + "optional": true + }, + "eslint-config-prettier": { + "optional": true + } + } + }, + "configs/eslint-config/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "configs/eslint-config/node_modules/fast-diff": { + "version": "1.3.0", + "dev": true, + "license": "Apache-2.0" + }, + "configs/eslint-config/node_modules/prettier-linter-helpers": { + "version": "1.0.0", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-diff": "^1.1.2" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "configs/eslint-config/node_modules/synckit": { + "version": "0.9.2", + "dev": true, + "license": "MIT", + "dependencies": { + "@pkgr/core": "^0.1.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/unts" + } + }, + "configs/eslint-config/node_modules/tslib": { + "version": "2.8.1", + "dev": true, + "license": "0BSD" + }, + "configs/tsconfig": { + "name": "@configs/tsconfig", + "version": "0.0.0" + }, + "node_modules/@configs/esbuild": { + "resolved": "configs/esbuild", + "link": true + }, + "node_modules/@configs/eslint-config": { + "resolved": "configs/eslint-config", + "link": true + }, + "node_modules/@configs/tsconfig": { + "resolved": "configs/tsconfig", + "link": true + }, + "node_modules/@elven.js/mobile-signing-provider": { + "resolved": "packages/mobile-signing-provider", + "link": true + }, "node_modules/@esbuild/aix-ppc64": { "version": "0.24.0", "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz", @@ -430,6 +786,18 @@ "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" } }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@eslint-community/regexpp": { "version": "4.12.1", "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", @@ -440,9 +808,9 @@ } }, "node_modules/@eslint/config-array": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", - "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.19.0.tgz", + "integrity": "sha512-zdHg2FPIFNKPdcHWtiNT+jEFCHYVplAXRDlQDyqy0zGx/q2parwh7brGJSiTxRk/TSMkbM//zt/f5CHgyTyaSQ==", "dev": true, "dependencies": { "@eslint/object-schema": "^2.1.4", @@ -454,18 +822,18 @@ } }, "node_modules/@eslint/core": { - "version": "0.7.0", - "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", - "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.9.0.tgz", + "integrity": "sha512-7ATR9F0e4W85D/0w7cU0SNj7qkAexMG+bAHEZOjo9akvGuhHE2m7umzWzfnpa0XAg5Kxc1BWmtPMV67jJ+9VUg==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, "node_modules/@eslint/eslintrc": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", - "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.2.0.tgz", + "integrity": "sha512-grOjVNN8P3hjJn/eIETF1wwd12DdnwFDoyceUJLYYdkpbwq3nLi+4fqrTAONx7XDALqlL220wC/RHSC/QTI/0w==", "dev": true, "dependencies": { "ajv": "^6.12.4", @@ -485,22 +853,10 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", - "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", - "dev": true, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/@eslint/js": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", - "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", + "version": "9.15.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.15.0.tgz", + "integrity": "sha512-tMTqrY+EzbXmKJR5ToI8lxu7jaN5EdmrBFJpQk5JmSlyLsx6o4t27r883K5xsLuCYCpfKBCGswMSWXsM+jB7lg==", "dev": true, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -516,9 +872,9 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", - "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.3.tgz", + "integrity": "sha512-2b/g5hRmpbb1o4GnTZax9N9m0FXzz9OV42ZzI4rDDMDuHUqigAiQCEWChBWCY4ztAGVRjoWT19v0yMmc5/L5kA==", "dev": true, "dependencies": { "levn": "^0.4.1" @@ -821,27 +1177,6 @@ "hash.js": "1.1.7" } }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", - "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", - "dev": true, - "dependencies": { - "bn.js": "^4.11.9", - "brorand": "^1.1.0", - "hash.js": "^1.0.0", - "hmac-drbg": "^1.0.1", - "inherits": "^2.0.4", - "minimalistic-assert": "^1.0.1", - "minimalistic-crypto-utils": "^1.0.1" - } - }, - "node_modules/@ethersproject/signing-key/node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "dev": true - }, "node_modules/@ethersproject/strings": { "version": "5.7.0", "resolved": "https://registry.npmjs.org/@ethersproject/strings/-/strings-5.7.0.tgz", @@ -962,9 +1297,9 @@ } }, "node_modules/@humanwhocodes/retry": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.0.tgz", - "integrity": "sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.1.tgz", + "integrity": "sha512-c7hNEllBlenFTHBky65mhq8WD2kbN9Q6gk0bTk8lSBvc554jpXSkST1iePudpt7+A/AQvuHs9EMqjHDXMY1lrA==", "dev": true, "engines": { "node": ">=18.18" @@ -1027,10 +1362,11 @@ } }, "node_modules/@parcel/watcher": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.4.1.tgz", - "integrity": "sha512-HNjmfLQEVRZmHRET336f20H/8kOozUGwk7yajvsonjNxbj2wBTK1WsQuHkD5yYh9RxFGL2EyDHryOihOwUoKDA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.0.tgz", + "integrity": "sha512-i0GV1yJnm2n3Yq1qw6QrUrd/LI9bE8WEBOTtOkpCXHHdyN3TAGgqAK/DAT05z4fq2x04cARXt2pDmjWjL92iTQ==", "dev": true, + "hasInstallScript": true, "dependencies": { "detect-libc": "^1.0.3", "is-glob": "^4.0.3", @@ -1045,24 +1381,25 @@ "url": "https://opencollective.com/parcel" }, "optionalDependencies": { - "@parcel/watcher-android-arm64": "2.4.1", - "@parcel/watcher-darwin-arm64": "2.4.1", - "@parcel/watcher-darwin-x64": "2.4.1", - "@parcel/watcher-freebsd-x64": "2.4.1", - "@parcel/watcher-linux-arm-glibc": "2.4.1", - "@parcel/watcher-linux-arm64-glibc": "2.4.1", - "@parcel/watcher-linux-arm64-musl": "2.4.1", - "@parcel/watcher-linux-x64-glibc": "2.4.1", - "@parcel/watcher-linux-x64-musl": "2.4.1", - "@parcel/watcher-win32-arm64": "2.4.1", - "@parcel/watcher-win32-ia32": "2.4.1", - "@parcel/watcher-win32-x64": "2.4.1" + "@parcel/watcher-android-arm64": "2.5.0", + "@parcel/watcher-darwin-arm64": "2.5.0", + "@parcel/watcher-darwin-x64": "2.5.0", + "@parcel/watcher-freebsd-x64": "2.5.0", + "@parcel/watcher-linux-arm-glibc": "2.5.0", + "@parcel/watcher-linux-arm-musl": "2.5.0", + "@parcel/watcher-linux-arm64-glibc": "2.5.0", + "@parcel/watcher-linux-arm64-musl": "2.5.0", + "@parcel/watcher-linux-x64-glibc": "2.5.0", + "@parcel/watcher-linux-x64-musl": "2.5.0", + "@parcel/watcher-win32-arm64": "2.5.0", + "@parcel/watcher-win32-ia32": "2.5.0", + "@parcel/watcher-win32-x64": "2.5.0" } }, "node_modules/@parcel/watcher-android-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.4.1.tgz", - "integrity": "sha512-LOi/WTbbh3aTn2RYddrO8pnapixAziFl6SMxHM69r3tvdSm94JtCenaKgk1GRg5FJ5wpMCpHeW+7yqPlvZv7kg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.0.tgz", + "integrity": "sha512-qlX4eS28bUcQCdribHkg/herLe+0A9RyYC+mm2PXpncit8z5b3nSqGVzMNR3CmtAOgRutiZ02eIJJgP/b1iEFQ==", "cpu": [ "arm64" ], @@ -1080,9 +1417,9 @@ } }, "node_modules/@parcel/watcher-darwin-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.4.1.tgz", - "integrity": "sha512-ln41eihm5YXIY043vBrrHfn94SIBlqOWmoROhsMVTSXGh0QahKGy77tfEywQ7v3NywyxBBkGIfrWRHm0hsKtzA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.0.tgz", + "integrity": "sha512-hyZ3TANnzGfLpRA2s/4U1kbw2ZI4qGxaRJbBH2DCSREFfubMswheh8TeiC1sGZ3z2jUf3s37P0BBlrD3sjVTUw==", "cpu": [ "arm64" ], @@ -1100,9 +1437,9 @@ } }, "node_modules/@parcel/watcher-darwin-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.4.1.tgz", - "integrity": "sha512-yrw81BRLjjtHyDu7J61oPuSoeYWR3lDElcPGJyOvIXmor6DEo7/G2u1o7I38cwlcoBHQFULqF6nesIX3tsEXMg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.0.tgz", + "integrity": "sha512-9rhlwd78saKf18fT869/poydQK8YqlU26TMiNg7AIu7eBp9adqbJZqmdFOsbZ5cnLp5XvRo9wcFmNHgHdWaGYA==", "cpu": [ "x64" ], @@ -1120,9 +1457,9 @@ } }, "node_modules/@parcel/watcher-freebsd-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.4.1.tgz", - "integrity": "sha512-TJa3Pex/gX3CWIx/Co8k+ykNdDCLx+TuZj3f3h7eOjgpdKM+Mnix37RYsYU4LHhiYJz3DK5nFCCra81p6g050w==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.0.tgz", + "integrity": "sha512-syvfhZzyM8kErg3VF0xpV8dixJ+RzbUaaGaeb7uDuz0D3FK97/mZ5AJQ3XNnDsXX7KkFNtyQyFrXZzQIcN49Tw==", "cpu": [ "x64" ], @@ -1140,9 +1477,29 @@ } }, "node_modules/@parcel/watcher-linux-arm-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.4.1.tgz", - "integrity": "sha512-4rVYDlsMEYfa537BRXxJ5UF4ddNwnr2/1O4MHM5PjI9cvV2qymvhwZSFgXqbS8YoTk5i/JR0L0JDs69BUn45YA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.0.tgz", + "integrity": "sha512-0VQY1K35DQET3dVYWpOaPFecqOT9dbuCfzjxoQyif1Wc574t3kOSkKevULddcR9znz1TcklCE7Ht6NIxjvTqLA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">= 10.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/@parcel/watcher-linux-arm-musl": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.0.tgz", + "integrity": "sha512-6uHywSIzz8+vi2lAzFeltnYbdHsDm3iIB57d4g5oaB9vKwjb6N6dRIgZMujw4nm5r6v9/BQH0noq6DzHrqr2pA==", "cpu": [ "arm" ], @@ -1160,9 +1517,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.4.1.tgz", - "integrity": "sha512-BJ7mH985OADVLpbrzCLgrJ3TOpiZggE9FMblfO65PlOCdG++xJpKUJ0Aol74ZUIYfb8WsRlUdgrZxKkz3zXWYA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.0.tgz", + "integrity": "sha512-BfNjXwZKxBy4WibDb/LDCriWSKLz+jJRL3cM/DllnHH5QUyoiUNEp3GmL80ZqxeumoADfCCP19+qiYiC8gUBjA==", "cpu": [ "arm64" ], @@ -1180,9 +1537,9 @@ } }, "node_modules/@parcel/watcher-linux-arm64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.4.1.tgz", - "integrity": "sha512-p4Xb7JGq3MLgAfYhslU2SjoV9G0kI0Xry0kuxeG/41UfpjHGOhv7UoUDAz/jb1u2elbhazy4rRBL8PegPJFBhA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.0.tgz", + "integrity": "sha512-S1qARKOphxfiBEkwLUbHjCY9BWPdWnW9j7f7Hb2jPplu8UZ3nes7zpPOW9bkLbHRvWM0WDTsjdOTUgW0xLBN1Q==", "cpu": [ "arm64" ], @@ -1200,9 +1557,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-glibc": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.4.1.tgz", - "integrity": "sha512-s9O3fByZ/2pyYDPoLM6zt92yu6P4E39a03zvO0qCHOTjxmt3GHRMLuRZEWhWLASTMSrrnVNWdVI/+pUElJBBBg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.0.tgz", + "integrity": "sha512-d9AOkusyXARkFD66S6zlGXyzx5RvY+chTP9Jp0ypSTC9d4lzyRs9ovGf/80VCxjKddcUvnsGwCHWuF2EoPgWjw==", "cpu": [ "x64" ], @@ -1220,9 +1577,9 @@ } }, "node_modules/@parcel/watcher-linux-x64-musl": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.4.1.tgz", - "integrity": "sha512-L2nZTYR1myLNST0O632g0Dx9LyMNHrn6TOt76sYxWLdff3cB22/GZX2UPtJnaqQPdCRoszoY5rcOj4oMTtp5fQ==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.0.tgz", + "integrity": "sha512-iqOC+GoTDoFyk/VYSFHwjHhYrk8bljW6zOhPuhi5t9ulqiYq1togGJB5e3PwYVFFfeVgc6pbz3JdQyDoBszVaA==", "cpu": [ "x64" ], @@ -1240,9 +1597,9 @@ } }, "node_modules/@parcel/watcher-wasm": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.4.1.tgz", - "integrity": "sha512-/ZR0RxqxU/xxDGzbzosMjh4W6NdYFMqq2nvo2b8SLi7rsl/4jkL8S5stIikorNkdR50oVDvqb/3JT05WM+CRRA==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-wasm/-/watcher-wasm-2.5.0.tgz", + "integrity": "sha512-Z4ouuR8Pfggk1EYYbTaIoxc+Yv4o7cGQnH0Xy8+pQ+HbiW+ZnwhcD2LPf/prfq1nIWpAxjOkQ8uSMFWMtBLiVQ==", "bundleDependencies": [ "napi-wasm" ], @@ -1267,9 +1624,9 @@ "license": "MIT" }, "node_modules/@parcel/watcher-win32-arm64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.4.1.tgz", - "integrity": "sha512-Uq2BPp5GWhrq/lcuItCHoqxjULU1QYEcyjSO5jqqOK8RNFDBQnenMMx4gAl3v8GiWa59E9+uDM7yZ6LxwUIfRg==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.0.tgz", + "integrity": "sha512-twtft1d+JRNkM5YbmexfcH/N4znDtjgysFaV9zvZmmJezQsKpkfLYJ+JFV3uygugK6AtIM2oADPkB2AdhBrNig==", "cpu": [ "arm64" ], @@ -1287,9 +1644,9 @@ } }, "node_modules/@parcel/watcher-win32-ia32": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.4.1.tgz", - "integrity": "sha512-maNRit5QQV2kgHFSYwftmPBxiuK5u4DXjbXx7q6eKjq5dsLXZ4FJiVvlcw35QXzk0KrUecJmuVFbj4uV9oYrcw==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.0.tgz", + "integrity": "sha512-+rgpsNRKwo8A53elqbbHXdOMtY/tAtTzManTWShB5Kk54N8Q9mzNWV7tV+IbGueCbcj826MfWGU3mprWtuf1TA==", "cpu": [ "ia32" ], @@ -1307,9 +1664,9 @@ } }, "node_modules/@parcel/watcher-win32-x64": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.4.1.tgz", - "integrity": "sha512-+DvS92F9ezicfswqrvIRM2njcYJbd5mb9CUgtrHCHmvn7pPPa+nMDRu1o1bYYz/l5IB2NVGNJWiH7h1E58IF2A==", + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.0.tgz", + "integrity": "sha512-lPrxve92zEHdgeff3aiu4gDOIt4u7sJYha6wbdEZDCDUhtjTsOMiaJzG5lMY4GkWH8p0fMmO2Ppq5G5XXG+DQw==", "cpu": [ "x64" ], @@ -1326,18 +1683,6 @@ "url": "https://opencollective.com/parcel" } }, - "node_modules/@pkgr/core": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.1.1.tgz", - "integrity": "sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==", - "dev": true, - "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, "node_modules/@stablelib/aead": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/aead/-/aead-1.0.1.tgz", @@ -1437,320 +1782,96 @@ "node_modules/@stablelib/keyagreement": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@stablelib/keyagreement/-/keyagreement-1.0.1.tgz", - "integrity": "sha512-VKL6xBwgJnI6l1jKrBAfn265cspaWBPAPEc62VBQrWHLqVgNRE09gQ/AnOEyKUWrrqfD+xSQ3u42gJjLDdMDQg==", - "dev": true, - "dependencies": { - "@stablelib/bytes": "^1.0.1" - } - }, - "node_modules/@stablelib/poly1305": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-1.0.1.tgz", - "integrity": "sha512-1HlG3oTSuQDOhSnLwJRKeTRSAdFNVB/1djy2ZbS35rBSJ/PFqx9cf9qatinWghC2UbfOYD8AcrtbUQl8WoxabA==", - "dev": true, - "dependencies": { - "@stablelib/constant-time": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/random": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@stablelib/random/-/random-1.0.2.tgz", - "integrity": "sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha256": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha256/-/sha256-1.0.1.tgz", - "integrity": "sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/sha512": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/sha512/-/sha512-1.0.1.tgz", - "integrity": "sha512-13gl/iawHV9zvDKciLo1fQ8Bgn2Pvf7OV6amaRVKiq3pjQ3UmEpXxWiAfV8tYjUpeZroBxtyrwtdooQT/i3hzw==", - "dev": true, - "dependencies": { - "@stablelib/binary": "^1.0.1", - "@stablelib/hash": "^1.0.1", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@stablelib/wipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", - "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==", - "dev": true - }, - "node_modules/@stablelib/x25519": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@stablelib/x25519/-/x25519-1.0.3.tgz", - "integrity": "sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw==", - "dev": true, - "dependencies": { - "@stablelib/keyagreement": "^1.0.1", - "@stablelib/random": "^1.0.2", - "@stablelib/wipe": "^1.0.1" - } - }, - "node_modules/@types/estree": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", - "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", - "dev": true - }, - "node_modules/@types/json-schema": { - "version": "7.0.15", - "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", - "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", - "dev": true - }, - "node_modules/@types/node": { - "version": "22.8.6", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.6.tgz", - "integrity": "sha512-tosuJYKrIqjQIlVCM4PEGxOmyg3FCPa/fViuJChnGeEIhjA46oy8FMVoF9su1/v8PNs2a8Q0iFNyOx0uOF91nw==", - "dev": true, - "dependencies": { - "undici-types": "~6.19.8" - } - }, - "node_modules/@types/qrcode": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.5.tgz", - "integrity": "sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@types/serve-handler": { - "version": "6.1.4", - "resolved": "https://registry.npmjs.org/@types/serve-handler/-/serve-handler-6.1.4.tgz", - "integrity": "sha512-aXy58tNie0NkuSCY291xUxl0X+kGYy986l4kqW6Gi4kEXgr6Tx0fpSH7YwUSa5usPpG3s9DBeIR6hHcDtL2IvQ==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.12.2.tgz", - "integrity": "sha512-gQxbxM8mcxBwaEmWdtLCIGLfixBMHhQjBqR8sVWNTPpcj45WlYL2IObS/DNMLH1DBP0n8qz+aiiLTGfopPEebw==", - "dev": true, - "dependencies": { - "@eslint-community/regexpp": "^4.10.0", - "@typescript-eslint/scope-manager": "8.12.2", - "@typescript-eslint/type-utils": "8.12.2", - "@typescript-eslint/utils": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2", - "graphemer": "^1.4.0", - "ignore": "^5.3.1", - "natural-compare": "^1.4.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "@typescript-eslint/parser": "^8.0.0 || ^8.0.0-alpha.0", - "eslint": "^8.57.0 || ^9.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/parser": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.12.2.tgz", - "integrity": "sha512-MrvlXNfGPLH3Z+r7Tk+Z5moZAc0dzdVjTgUgwsdGweH7lydysQsnSww3nAmsq8blFuRD5VRlAr9YdEFw3e6PBw==", - "dev": true, - "dependencies": { - "@typescript-eslint/scope-manager": "8.12.2", - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/typescript-estree": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2", - "debug": "^4.3.4" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } - } - }, - "node_modules/@typescript-eslint/scope-manager": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.12.2.tgz", - "integrity": "sha512-gPLpLtrj9aMHOvxJkSbDBmbRuYdtiEbnvO25bCMza3DhMjTQw0u7Y1M+YR5JPbMsXXnSPuCf5hfq0nEkQDL/JQ==", - "dev": true, - "dependencies": { - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - } - }, - "node_modules/@typescript-eslint/type-utils": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.12.2.tgz", - "integrity": "sha512-bwuU4TAogPI+1q/IJSKuD4shBLc/d2vGcRT588q+jzayQyjVK2X6v/fbR4InY2U2sgf8MEvVCqEWUzYzgBNcGQ==", + "integrity": "sha512-VKL6xBwgJnI6l1jKrBAfn265cspaWBPAPEc62VBQrWHLqVgNRE09gQ/AnOEyKUWrrqfD+xSQ3u42gJjLDdMDQg==", "dev": true, "dependencies": { - "@typescript-eslint/typescript-estree": "8.12.2", - "@typescript-eslint/utils": "8.12.2", - "debug": "^4.3.4", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } + "@stablelib/bytes": "^1.0.1" } }, - "node_modules/@typescript-eslint/types": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.12.2.tgz", - "integrity": "sha512-VwDwMF1SZ7wPBUZwmMdnDJ6sIFk4K4s+ALKLP6aIQsISkPv8jhiw65sAK6SuWODN/ix+m+HgbYDkH+zLjrzvOA==", + "node_modules/@stablelib/poly1305": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/poly1305/-/poly1305-1.0.1.tgz", + "integrity": "sha512-1HlG3oTSuQDOhSnLwJRKeTRSAdFNVB/1djy2ZbS35rBSJ/PFqx9cf9qatinWghC2UbfOYD8AcrtbUQl8WoxabA==", "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "dependencies": { + "@stablelib/constant-time": "^1.0.1", + "@stablelib/wipe": "^1.0.1" } }, - "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.12.2.tgz", - "integrity": "sha512-mME5MDwGe30Pq9zKPvyduyU86PH7aixwqYR2grTglAdB+AN8xXQ1vFGpYaUSJ5o5P/5znsSBeNcs5g5/2aQwow==", + "node_modules/@stablelib/random": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@stablelib/random/-/random-1.0.2.tgz", + "integrity": "sha512-rIsE83Xpb7clHPVRlBj8qNe5L8ISQOzjghYQm/dZ7VaM2KHYwMW5adjQjrzTZCchFnNCNhkwtnOBa9HTMJCI8w==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/visitor-keys": "8.12.2", - "debug": "^4.3.4", - "fast-glob": "^3.3.2", - "is-glob": "^4.0.3", - "minimatch": "^9.0.4", - "semver": "^7.6.0", - "ts-api-utils": "^1.3.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependenciesMeta": { - "typescript": { - "optional": true - } + "@stablelib/binary": "^1.0.1", + "@stablelib/wipe": "^1.0.1" } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "node_modules/@stablelib/sha256": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/sha256/-/sha256-1.0.1.tgz", + "integrity": "sha512-GIIH3e6KH+91FqGV42Kcj71Uefd/QEe7Dy42sBTeqppXV95ggCcxLTk39bEr+lZfJmp+ghsR07J++ORkRELsBQ==", "dev": true, "dependencies": { - "balanced-match": "^1.0.0" + "@stablelib/binary": "^1.0.1", + "@stablelib/hash": "^1.0.1", + "@stablelib/wipe": "^1.0.1" } }, - "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { - "version": "9.0.5", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", - "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "node_modules/@stablelib/sha512": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/sha512/-/sha512-1.0.1.tgz", + "integrity": "sha512-13gl/iawHV9zvDKciLo1fQ8Bgn2Pvf7OV6amaRVKiq3pjQ3UmEpXxWiAfV8tYjUpeZroBxtyrwtdooQT/i3hzw==", "dev": true, "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" + "@stablelib/binary": "^1.0.1", + "@stablelib/hash": "^1.0.1", + "@stablelib/wipe": "^1.0.1" } }, - "node_modules/@typescript-eslint/utils": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.12.2.tgz", - "integrity": "sha512-UTTuDIX3fkfAz6iSVa5rTuSfWIYZ6ATtEocQ/umkRSyC9O919lbZ8dcH7mysshrCdrAM03skJOEYaBugxN+M6A==", + "node_modules/@stablelib/wipe": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@stablelib/wipe/-/wipe-1.0.1.tgz", + "integrity": "sha512-WfqfX/eXGiAd3RJe4VU2snh/ZPwtSjLG4ynQ/vYzvghTh7dHFcI1wl+nrkWG6lGhukOxOsUHfv8dUXr58D0ayg==", + "dev": true + }, + "node_modules/@stablelib/x25519": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@stablelib/x25519/-/x25519-1.0.3.tgz", + "integrity": "sha512-KnTbKmUhPhHavzobclVJQG5kuivH+qDLpe84iRqX3CLrKp881cF160JvXJ+hjn1aMyCwYOKeIZefIH/P5cJoRw==", "dev": true, "dependencies": { - "@eslint-community/eslint-utils": "^4.4.0", - "@typescript-eslint/scope-manager": "8.12.2", - "@typescript-eslint/types": "8.12.2", - "@typescript-eslint/typescript-estree": "8.12.2" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" - }, - "peerDependencies": { - "eslint": "^8.57.0 || ^9.0.0" + "@stablelib/keyagreement": "^1.0.1", + "@stablelib/random": "^1.0.2", + "@stablelib/wipe": "^1.0.1" } }, - "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.12.2", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.12.2.tgz", - "integrity": "sha512-PChz8UaKQAVNHghsHcPyx1OMHoFRUEA7rJSK/mDhdq85bk+PLsUHUBqTQTFt18VJZbmxBovM65fezlheQRsSDA==", + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true + }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true + }, + "node_modules/@types/node": { + "version": "22.9.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.9.0.tgz", + "integrity": "sha512-vuyHg81vvWA1Z1ELfvLko2c8f34gyA0zaic0+Rllc5lbCnbSyuvb2Oxpm6TAUAC/2xZN3QGqxBNggD1nNR2AfQ==", "dev": true, "dependencies": { - "@typescript-eslint/types": "8.12.2", - "eslint-visitor-keys": "^3.4.3" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/typescript-eslint" + "undici-types": "~6.19.8" } }, "node_modules/@walletconnect/core": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.1.tgz", - "integrity": "sha512-SMgJR5hEyEE/tENIuvlEb4aB9tmMXPzQ38Y61VgYBmwAFEhOHtpt8EDfnfRWqEhMyXuBXG4K70Yh8c67Yry+Xw==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/core/-/core-2.17.2.tgz", + "integrity": "sha512-O9VUsFg78CbvIaxfQuZMsHcJ4a2Z16DRz/O4S+uOAcGKhH/i/ln8hp864Tb+xRvifWSzaZ6CeAVxk657F+pscA==", "dev": true, "dependencies": { "@walletconnect/heartbeat": "1.2.2", @@ -1764,8 +1885,8 @@ "@walletconnect/relay-auth": "1.0.4", "@walletconnect/safe-json": "1.0.2", "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", "@walletconnect/window-getters": "1.0.1", "events": "3.3.0", "lodash.isequal": "4.5.0", @@ -1911,19 +2032,19 @@ } }, "node_modules/@walletconnect/sign-client": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.17.1.tgz", - "integrity": "sha512-6rLw6YNy0smslH9wrFTbNiYrGsL3DrOsS5FcuU4gIN6oh8pGYOFZ5FiSyTTroc5tngOk3/Sd7dlGY9S7O4nveg==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/sign-client/-/sign-client-2.17.2.tgz", + "integrity": "sha512-/wigdCIQjlBXSWY43Id0IPvZ5biq4HiiQZti8Ljvx408UYjmqcxcBitbj2UJXMYkid7704JWAB2mw32I1HgshQ==", "dev": true, "dependencies": { - "@walletconnect/core": "2.17.1", + "@walletconnect/core": "2.17.2", "@walletconnect/events": "1.0.1", "@walletconnect/heartbeat": "1.2.2", "@walletconnect/jsonrpc-utils": "1.0.8", "@walletconnect/logger": "2.1.2", "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", - "@walletconnect/utils": "2.17.1", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", "events": "3.3.0" } }, @@ -1937,9 +2058,9 @@ } }, "node_modules/@walletconnect/types": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.17.1.tgz", - "integrity": "sha512-aiUeBE3EZZTsZBv5Cju3D0PWAsZCMks1g3hzQs9oNtrbuLL6pKKU0/zpKwk4vGywszxPvC3U0tBCku9LLsH/0A==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/types/-/types-2.17.2.tgz", + "integrity": "sha512-j/+0WuO00lR8ntu7b1+MKe/r59hNwYLFzW0tTmozzhfAlDL+dYwWasDBNq4AH8NbVd7vlPCQWmncH7/6FVtOfQ==", "dev": true, "dependencies": { "@walletconnect/events": "1.0.1", @@ -1951,9 +2072,9 @@ } }, "node_modules/@walletconnect/utils": { - "version": "2.17.1", - "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.17.1.tgz", - "integrity": "sha512-KL7pPwq7qUC+zcTmvxGqIyYanfHgBQ+PFd0TEblg88jM7EjuDLhjyyjtkhyE/2q7QgR7OanIK7pCpilhWvBsBQ==", + "version": "2.17.2", + "resolved": "https://registry.npmjs.org/@walletconnect/utils/-/utils-2.17.2.tgz", + "integrity": "sha512-T7eLRiuw96fgwUy2A5NZB5Eu87ukX8RCVoO9lji34RFV4o2IGU9FhTEWyd4QQKI8OuQRjSknhbJs0tU0r0faPw==", "dev": true, "dependencies": { "@ethersproject/hash": "5.7.0", @@ -1969,11 +2090,11 @@ "@walletconnect/relay-auth": "1.0.4", "@walletconnect/safe-json": "1.0.2", "@walletconnect/time": "1.0.2", - "@walletconnect/types": "2.17.1", + "@walletconnect/types": "2.17.2", "@walletconnect/window-getters": "1.0.1", "@walletconnect/window-metadata": "1.0.1", "detect-browser": "5.3.0", - "elliptic": "6.5.7", + "elliptic": "6.6.0", "query-string": "7.1.3", "uint8arrays": "3.1.0" } @@ -2159,15 +2280,6 @@ "node": ">=6" } }, - "node_modules/camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", @@ -2246,72 +2358,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" - } - }, - "node_modules/cliui/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/cliui/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/cliui/node_modules/wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -2367,9 +2413,9 @@ "dev": true }, "node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "version": "7.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.5.tgz", + "integrity": "sha512-ZVJrKKYunU38/76t0RMOulHOnUcbU9GbpWKAOZ0mhjr7CX6FVrH+4FrAapSOekrgFQ3f/8gwMEuIft0aKq6Hug==", "dev": true, "dependencies": { "path-key": "^3.1.0", @@ -2406,15 +2452,6 @@ } } }, - "node_modules/decamelize": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", - "integrity": "sha512-z2S+W9X73hAUUki+N+9Za2lBlun89zigOyGrsax+KUQ6wKW4ZoWpEYBkGhQjwAjjDCkWxhY0VKEhk8wzY7F5cA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/decode-uri-component": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz", @@ -2460,12 +2497,6 @@ "node": ">=0.10" } }, - "node_modules/dijkstrajs": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/dijkstrajs/-/dijkstrajs-1.0.3.tgz", - "integrity": "sha512-qiSlmBq9+BCdCA/L46dw8Uy93mloxsPSbwnm5yrKn2vMPiy8KyAskTF6zuV/j5BMsmOGZDPs7KjU+mjb670kfA==", - "dev": true - }, "node_modules/duplexify": { "version": "4.1.3", "resolved": "https://registry.npmjs.org/duplexify/-/duplexify-4.1.3.tgz", @@ -2485,9 +2516,9 @@ "dev": true }, "node_modules/elliptic": { - "version": "6.5.7", - "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.7.tgz", - "integrity": "sha512-ESVCtTwiA+XhY3wyh24QqRGBoP3rEdDUl3EDUUo9tft074fi19IrdpH7hLCMMP3CIj7jb3W96rn8lt/BqIlt5Q==", + "version": "6.6.0", + "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.6.0.tgz", + "integrity": "sha512-dpwoQcLc/2WLQvJvLRHKZ+f9FgOdjnq11rurqwekGQygGPsYSK29OMMD2WalatiqQ+XGFDglTNixpPfI+lpaAA==", "dev": true, "dependencies": { "bn.js": "^4.11.9", @@ -2500,11 +2531,15 @@ } }, "node_modules/elliptic/node_modules/bn.js": { - "version": "4.12.0", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", - "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.1.tgz", + "integrity": "sha512-k8TVBiPkPJT9uHLdOKfFpqcfprwBFOAAXXozRubr7R7PfIuKvQlzcI4M0pALeqXN09vdaMbUdUj+pass+uULAg==", "dev": true }, + "node_modules/elven.js": { + "resolved": "packages/elven.js", + "link": true + }, "node_modules/emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -2572,26 +2607,26 @@ } }, "node_modules/eslint": { - "version": "9.14.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", - "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", + "version": "9.15.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.15.0.tgz", + "integrity": "sha512-7CrWySmIibCgT1Os28lUU6upBshZ+GxybLOrmRzi08kS8MBuO8QA7pXEgYgY5W8vK3e74xv0lpjo9DbaGU9Rkw==", "dev": true, "dependencies": { "@eslint-community/eslint-utils": "^4.2.0", "@eslint-community/regexpp": "^4.12.1", - "@eslint/config-array": "^0.18.0", - "@eslint/core": "^0.7.0", - "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "9.14.0", - "@eslint/plugin-kit": "^0.2.0", + "@eslint/config-array": "^0.19.0", + "@eslint/core": "^0.9.0", + "@eslint/eslintrc": "^3.2.0", + "@eslint/js": "9.15.0", + "@eslint/plugin-kit": "^0.2.3", "@humanfs/node": "^0.16.6", "@humanwhocodes/module-importer": "^1.0.1", - "@humanwhocodes/retry": "^0.4.0", + "@humanwhocodes/retry": "^0.4.1", "@types/estree": "^1.0.6", "@types/json-schema": "^7.0.15", "ajv": "^6.12.4", "chalk": "^4.0.0", - "cross-spawn": "^7.0.2", + "cross-spawn": "^7.0.5", "debug": "^4.3.2", "escape-string-regexp": "^4.0.0", "eslint-scope": "^8.2.0", @@ -2610,8 +2645,7 @@ "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.3", - "text-table": "^0.2.0" + "optionator": "^0.9.3" }, "bin": { "eslint": "bin/eslint.js" @@ -2631,48 +2665,6 @@ } } }, - "node_modules/eslint-config-prettier": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz", - "integrity": "sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==", - "dev": true, - "bin": { - "eslint-config-prettier": "bin/cli.js" - }, - "peerDependencies": { - "eslint": ">=7.0.0" - } - }, - "node_modules/eslint-plugin-prettier": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz", - "integrity": "sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==", - "dev": true, - "dependencies": { - "prettier-linter-helpers": "^1.0.0", - "synckit": "^0.9.1" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/eslint-plugin-prettier" - }, - "peerDependencies": { - "@types/eslint": ">=8.0.0", - "eslint": ">=8.0.0", - "eslint-config-prettier": "*", - "prettier": ">=3.0.0" - }, - "peerDependenciesMeta": { - "@types/eslint": { - "optional": true - }, - "eslint-config-prettier": { - "optional": true - } - } - }, "node_modules/eslint-scope": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", @@ -2680,28 +2672,16 @@ "dev": true, "dependencies": { "esrecurse": "^4.3.0", - "estraverse": "^5.2.0" - }, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "3.4.3", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", - "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", - "dev": true, + "estraverse": "^5.2.0" + }, "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" }, "funding": { "url": "https://opencollective.com/eslint" } }, - "node_modules/eslint/node_modules/eslint-visitor-keys": { + "node_modules/eslint-visitor-keys": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", @@ -2730,18 +2710,6 @@ "url": "https://opencollective.com/eslint" } }, - "node_modules/espree/node_modules/eslint-visitor-keys": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", - "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", - "dev": true, - "engines": { - "node": "^18.18.0 || ^20.9.0 || >=21.1.0" - }, - "funding": { - "url": "https://opencollective.com/eslint" - } - }, "node_modules/esquery": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", @@ -2822,12 +2790,6 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "dev": true }, - "node_modules/fast-diff": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.3.0.tgz", - "integrity": "sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==", - "dev": true - }, "node_modules/fast-glob": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", @@ -2984,15 +2946,6 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, - "node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, "node_modules/get-port-please": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/get-port-please/-/get-port-please-3.1.2.tgz", @@ -3071,9 +3024,9 @@ } }, "node_modules/globals": { - "version": "15.11.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-15.11.0.tgz", - "integrity": "sha512-yeyNSjdbyVaWurlwCpcA6XNBrHTMIeDdj0/hnvX/OLJ9ekOXYbLsLinH/MucQyGvNnXhidTdNhTtJaffL2sMfw==", + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", "dev": true, "engines": { "node": ">=18" @@ -3603,14 +3556,14 @@ } }, "node_modules/mlly": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.2.tgz", - "integrity": "sha512-tN3dvVHYVz4DhSXinXIk7u9syPYaJvio118uomkovAtWBT+RdbP6Lfh/5Lvo519YMmwBafwlh20IPTXIStscpA==", + "version": "1.7.3", + "resolved": "https://registry.npmjs.org/mlly/-/mlly-1.7.3.tgz", + "integrity": "sha512-xUsx5n/mN0uQf4V548PKQ+YShA4/IW0KI1dZhrNrPCLG+xizETbHTkOa1f8/xut9JRPp8kQuMnz0oqwkTiLo/A==", "dev": true, "dependencies": { - "acorn": "^8.12.1", + "acorn": "^8.14.0", "pathe": "^1.1.2", - "pkg-types": "^1.2.0", + "pkg-types": "^1.2.1", "ufo": "^1.5.4" } }, @@ -3783,15 +3736,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/p-try": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", - "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", - "dev": true, - "engines": { - "node": ">=6" - } - }, "node_modules/package-json-from-dist": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", @@ -3923,15 +3867,6 @@ "pathe": "^1.1.2" } }, - "node_modules/pngjs": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/pngjs/-/pngjs-5.0.0.tgz", - "integrity": "sha512-40QW5YalBNfQo5yRYmiw7Yz6TKKVr3h6970B2YE+3fQpsWcrbj1PzJgxeJ19DRQjhMbKPIuMY8rFaXc8moolVw==", - "dev": true, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/prelude-ls": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", @@ -3956,18 +3891,6 @@ "url": "https://github.com/prettier/prettier?sponsor=1" } }, - "node_modules/prettier-linter-helpers": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz", - "integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==", - "dev": true, - "dependencies": { - "fast-diff": "^1.1.2" - }, - "engines": { - "node": ">=6.0.0" - } - }, "node_modules/process-warning": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/process-warning/-/process-warning-1.0.0.tgz", @@ -3983,23 +3906,6 @@ "node": ">=6" } }, - "node_modules/qrcode": { - "version": "1.5.4", - "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", - "integrity": "sha512-1ca71Zgiu6ORjHqFBDpnSMTR2ReToX4l1Au1VFLyVeBTFavzQnv5JxMFr3ukHVKpSrSA2MCk0lNJSykjUfz7Zg==", - "dev": true, - "dependencies": { - "dijkstrajs": "^1.0.1", - "pngjs": "^5.0.0", - "yargs": "^15.3.1" - }, - "bin": { - "qrcode": "bin/qrcode" - }, - "engines": { - "node": ">=10.13.0" - } - }, "node_modules/query-string": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.1.3.tgz", @@ -4094,21 +4000,6 @@ "node": ">= 12.13.0" } }, - "node_modules/require-directory": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, - "node_modules/require-main-filename": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", - "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", - "dev": true - }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -4226,12 +4117,6 @@ "range-parser": "1.2.0" } }, - "node_modules/set-blocking": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", - "dev": true - }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -4293,9 +4178,9 @@ } }, "node_modules/std-env": { - "version": "3.7.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.7.0.tgz", - "integrity": "sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==", + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", + "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", "dev": true }, "node_modules/stream-shift": { @@ -4454,28 +4339,6 @@ "node": ">=8" } }, - "node_modules/synckit": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.9.2.tgz", - "integrity": "sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==", - "dev": true, - "dependencies": { - "@pkgr/core": "^0.1.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": "^14.18.0 || >=16.0.0" - }, - "funding": { - "url": "https://opencollective.com/unts" - } - }, - "node_modules/synckit/node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true - }, "node_modules/system-architecture": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/system-architecture/-/system-architecture-0.1.0.tgz", @@ -4488,12 +4351,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/text-table": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true - }, "node_modules/thread-stream": { "version": "0.15.2", "resolved": "https://registry.npmjs.org/thread-stream/-/thread-stream-0.15.2.tgz", @@ -4533,6 +4390,101 @@ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==", "dev": true }, + "node_modules/turbo": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo/-/turbo-2.3.0.tgz", + "integrity": "sha512-/uOq5o2jwRPyaUDnwBpOR5k9mQq4c3wziBgWNWttiYQPmbhDtrKYPRBxTvA2WpgQwRIbt8UM612RMN8n/TvmHA==", + "dev": true, + "bin": { + "turbo": "bin/turbo" + }, + "optionalDependencies": { + "turbo-darwin-64": "2.3.0", + "turbo-darwin-arm64": "2.3.0", + "turbo-linux-64": "2.3.0", + "turbo-linux-arm64": "2.3.0", + "turbo-windows-64": "2.3.0", + "turbo-windows-arm64": "2.3.0" + } + }, + "node_modules/turbo-darwin-64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-darwin-64/-/turbo-darwin-64-2.3.0.tgz", + "integrity": "sha512-pji+D49PhFItyQjf2QVoLZw2d3oRGo8gJgKyOiRzvip78Rzie74quA8XNwSg/DuzM7xx6gJ3p2/LylTTlgZXxQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/turbo-darwin-arm64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-darwin-arm64/-/turbo-darwin-arm64-2.3.0.tgz", + "integrity": "sha512-AJrGIL9BO41mwDF/IBHsNGwvtdyB911vp8f5mbNo1wG66gWTvOBg7WCtYQBvCo11XTenTfXPRSsAb7w3WAZb6w==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/turbo-linux-64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-linux-64/-/turbo-linux-64-2.3.0.tgz", + "integrity": "sha512-jZqW6vc2sPJT3M/3ZmV1Cg4ecQVPqsbHncG/RnogHpBu783KCSXIndgxvUQNm9qfgBYbZDBnP1md63O4UTElhw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/turbo-linux-arm64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-linux-arm64/-/turbo-linux-arm64-2.3.0.tgz", + "integrity": "sha512-HUbDLJlvd/hxuyCNO0BmEWYQj0TugRMvSQeG8vHJH+Lq8qOgDAe7J0K73bFNbZejZQxW3C3XEiZFB3pnpO78+A==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/turbo-windows-64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-windows-64/-/turbo-windows-64-2.3.0.tgz", + "integrity": "sha512-c5rxrGNTYDWX9QeMzWLFE9frOXnKjHGEvQMp1SfldDlbZYsloX9UKs31TzUThzfTgTiz8NYuShaXJ2UvTMnV/g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/turbo-windows-arm64": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/turbo-windows-arm64/-/turbo-windows-arm64-2.3.0.tgz", + "integrity": "sha512-7qfUuYhfIVb1AZgs89DxhXK+zZez6O2ocmixEQ4hXZK7ytnBt5vaz2zGNJJKFNYIL5HX1C3tuHolnpNgDNCUIg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -4728,12 +4680,6 @@ "node": ">= 8" } }, - "node_modules/which-module": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", - "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", - "dev": true - }, "node_modules/word-wrap": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", @@ -4858,140 +4804,6 @@ } } }, - "node_modules/y18n": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.3.tgz", - "integrity": "sha512-JKhqTOwSrqNA1NY5lSztJ1GrBiUodLMmIZuLiDaMRJ+itFd+ABVE8XBjOvIWL+rSqNDC74LCSFmlb/U4UZ4hJQ==", - "dev": true - }, - "node_modules/yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "dev": true, - "dependencies": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", - "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", - "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "dev": true, - "dependencies": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "engines": { - "node": ">=6" - } - }, - "node_modules/yargs/node_modules/ansi-regex": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", - "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/emoji-regex": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", - "dev": true - }, - "node_modules/yargs/node_modules/find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "dev": true, - "dependencies": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "dev": true, - "dependencies": { - "p-locate": "^4.1.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/p-limit": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", - "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", - "dev": true, - "dependencies": { - "p-try": "^2.0.0" - }, - "engines": { - "node": ">=6" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, - "node_modules/yargs/node_modules/p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "dev": true, - "dependencies": { - "p-limit": "^2.2.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/yargs/node_modules/strip-ansi": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "dependencies": { - "ansi-regex": "^5.0.1" - }, - "engines": { - "node": ">=8" - } - }, "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", @@ -5003,6 +4815,22 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } + }, + "packages/elven.js": { + "version": "1.0.0" + }, + "packages/mobile-signing-provider": { + "name": "@elven.js/mobile-signing-provider", + "version": "1.0.0", + "devDependencies": { + "@walletconnect/sign-client": "2.17.2", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", + "uqr": "0.1.2" + }, + "peerDependencies": { + "elven.js": "*" + } } } } diff --git a/package.json b/package.json index a759c95..378be48 100644 --- a/package.json +++ b/package.json @@ -1,62 +1,33 @@ { - "name": "elven.js", - "version": "1.0.0", - "description": "Sync, sign and send transactions on the MultiversX blockchain in the browser.", + "name": "elven.js-monorepo", + "private": true, "type": "module", - "module": "build/elven.js", - "types": "build/types/elven.d.ts", - "exports": { - ".": { - "types": "./build/types/elven.d.ts", - "import": "./build/elven.js", - "browser": "./build/elven.js", - "default": "./build/elven.js" - }, - "./package.json": "./package.json" - }, - "sideEffects": false, - "author": "Julian Ćwirko ", - "license": "MIT", - "homepage": "https://www.elvenjs.com", - "repository": { - "type": "git", - "url": "git+https://github.com/elven-js/elven.js.git" - }, - "keywords": [ - "elrond", - "multiversx", - "xPortal", - "blockchain", - "sdk", - "javascript", - "browser", - "xalias" + "packageManager": "npm@10.9.0", + "workspaces": [ + "packages/*", + "configs/*" ], "scripts": { - "build": "rimraf build && node ./esbuild.config.cjs && tsc && cp build/elven.js example/elven.js", - "dev:server": "node dev-server.mjs", - "lint": "eslint src/** --fix", - "prettier": "prettier --write 'src/**/*.{js,ts,json}'", - "check-types": "tsc", - "prepublishOnly": "npm run build" + "build": "turbo run build", + "dev:server": "node dev-server.js", + "lint": "turbo run lint", + "check-types": "turbo run check-types", + "prettier": "turbo run prettier", + "clean": "turbo run clean && rm -rf node_modules" }, "devDependencies": { - "@eslint/eslintrc": "3.1.0", - "@eslint/js": "9.14.0", - "@types/qrcode": "1.5.5", - "@types/serve-handler": "6.1.4", - "@typescript-eslint/eslint-plugin": "8.12.2", - "@typescript-eslint/parser": "8.12.2", - "@walletconnect/sign-client": "^2.17.1", - "esbuild": "0.24.0", - "eslint": "9.14.0", - "eslint-config-prettier": "9.1.0", - "eslint-plugin-prettier": "5.2.1", - "globals": "15.11.0", + "@configs/esbuild": "workspace:*", + "@configs/eslint-config": "workspace:*", + "@configs/tsconfig": "workspace:*", + "@types/node": "22.9.0", + "eslint": "9.15.0", "prettier": "3.3.3", - "qrcode": "1.5.4", "rimraf": "6.0.1", "serve-handler": "6.1.6", + "turbo": "2.3.0", "typescript": "5.6.3" + }, + "overrides": { + "elliptic": "6.6.0" } } \ No newline at end of file diff --git a/CHANGELOG.md b/packages/elven.js/CHANGELOG.md similarity index 98% rename from CHANGELOG.md rename to packages/elven.js/CHANGELOG.md index a3260d4..e370ae7 100644 --- a/CHANGELOG.md +++ b/packages/elven.js/CHANGELOG.md @@ -3,7 +3,8 @@ - introduce new API (breaking changes) - add esbuild adjustments - elven.js script is now much smaller -- add some most crucial automatic tests +- add some most crucial automated tests +- xPortal signing provider is now extracted as separate JS file to be used as optional signing providers - ... ### [0.20.0](https://github.com/elven-js/elven.js/releases/tag/v0.20.0) (2024-10-13) diff --git a/packages/elven.js/README.md b/packages/elven.js/README.md new file mode 100644 index 0000000..ddf4bf3 --- /dev/null +++ b/packages/elven.js/README.md @@ -0,0 +1,167 @@ +## ElvenJS + +### One static file to rule it all on the MultiversX blockchain! + +## Docs +- [www.elvenjs.com](https://www.elvenjs.com) + +## Videos +- [JavaScript browser SDK for MultiversX Blockchain](https://youtu.be/tcTukpkjcQw) + +## Demos +- [elvenjs.netlify.app](https://elvenjs.netlify.app/) - EGLD, ESDT transactions, smart contract queries and transactions +- [elrond-donate-widget-demo.netlify.app](https://multiversx-donate-widget-demo.netlify.app/) - donation-like widget demo +- [StackBlitz vanilla html demo](https://stackblitz.com/edit/web-platform-d4rx5v?file=index.html) +- [StackBlitz Solid.js demo](https://stackblitz.com/edit/vitejs-vite-rbo6du?file=src/App.tsx) +- [StackBlitz React demo](https://stackblitz.com/edit/vitejs-vite-qr2u7l?file=src/App.tsx) +- [StackBlitz Vue demo](https://stackblitz.com/edit/vue-zrb8y5?file=src/App.vue) + +Authenticate, sign and send transactions on the MultiversX blockchain in the browser. No need for bundlers, frameworks, etc. Just attach the script source, and you are ready to go. You can incorporate it into your preferred CMS framework like WordPress or an e-commerce system. Plus, it will also work on a standard static HTML website. + +The primary purpose of this tool is to have a lite script for browser usage where you can authenticate and sign/send transactions on the MultiversX blockchain and do this without any additional build steps. + +The purpose is to simplify the usage for primary use cases and open the doors for many frontend tools and approaches. + +It is a script for browsers incorporates ES6 modules. If you need fully functional JavaScript/Typescript SDK (also in Nodejs), please use [sdk-js](https://docs.multiversx.com/sdk-and-tools/sdk-js/), an official Typescript MultiversX SDK. And if you are React developer, please check the [Nextjs dapp](https://github.com/xdevguild/nextjs-dapp-template). + +**You can use it already, but it is under active development, and the API might change, there could be breaking changes without changing major versions.** + +### How to use it + +Copy and include the `elven.js` script from the `build` directory or the best would be to use CDN (https://unpkg.com/elven.js/build/elven.js). Please don't link the script using the [demo](https://elvenjs.netlify.app/) domain. + +Use module type, like: + +```html + +``` +or from CDN: + +```html + +``` + +### SDK reference + +Please check the docs here: [www.elvenjs.com/docs/sdk-reference.html](https://www.elvenjs.com/docs/sdk-reference.html) + +### Recipes + +Please check how to use it with a couple of recipes here: [www.elvenjs.com/docs/recipes.html](https://www.elvenjs.com/docs/recipes.html) + +Check for more complete examples in the [example/index.html](/example/index.html) + +### Usage example with static website (base demo): + +Check out the example file: [example/index.html](/example/index.html) + +You will find the whole demo there. The same is deployed here: [elvenjs.netlify.app](https://elvenjs.netlify.app) + +### Usage in frontend frameworks + +Elven.js can also be used in many different frameworks by importing it from node_modules (of course, it is a client-side library). When it comes to React/Nextjs, it is advised to use one of the ready templates, for example, the one mentioned above. But Elven.js can be helpful in other frameworks where there are no templates yet. Example: + +```bash +npm install elven.js +``` +and then in your client side framework: +```typescript +import { ElvenJS } from 'elven.js'; +``` + +The types should also be exported. + +### What can it do? + +The API is limited for now, this will change, but even now, it can do most of the core operations: + +- authenticate using the xPortal mobile, MultiversX browser extension, MultiversX Web Wallet and xAlias +- integrate with xPortal Hub +- handle expiration of the auth state +- handle login with tokens to be able to get the signature +- sign transactions +- send transactions (also custom smart contracts) +- sign custom messages +- basic global states handling (local storage) +- basic structures for transaction payload +- sync the network on page load +- querying the smart contracts (without tools for result parsing yet) +- support for guarded transactions using MultiversX 2FA solutions + +### What will it do soon? (TODO): + +- authenticate with Ledger Nano +- result parsing (separate library) +- more advanced global state handling and (real-time updates (if needed)?) +- more structures and simplification for payload builders +- split it into more files/libraries +- make it as small as possible + +### What it won't probably do: + +- crypto tasks +- results parsing (but it will land in a separate package) + +Why? Because it is supposed to be a browser script, it should be as small as possible. All that functionality can be replaced if needed by a custom implementation or other libraries. There will be docs with examples for that. And in the future, there may be more similar libraries, but optional and separated. + +### Development + +1. clone the repo +2. `npm install` dependencies +3. `npm run build` +4. test on example -> `npm run dev:server` +5. rebuild with every change in the script + +To test the MultiversX browser extension you would need to run localhost with SSL. +For quick dev testing tools like [localhost.run](https://localhost.run/) should be enough. +After you run `npm run dev:server`, in separate teriminal window run `ssh -R 80:localhost:3000 localhost.run`. You can also relay on your own SSL setup. + +### Articles + +- [How to Interact With the MultiversX Blockchain in a Simple Static Website](https://hackernoon.com/how-to-interact-with-the-elrond-blockchain-in-a-simple-static-website) +- [How to enable donations on any website using the MultiversX blockchain and EGLD tokens](https://dev.to/juliancwirko/how-to-enable-donations-on-any-website-using-the-elrond-blockchain-and-egld-tokens-3fkf) + +### TODO +- [Kanban board](https://github.com/elven-js/projects/1) + +### Other tools + +If you need to use MultiversX SDK with React-based projects, you can try these tools: + +- [sdk-dapp](https://github.com/multiversx/mx-sdk-dapp) - for standard React-based SPA +- [nextjs-dapp-template](https://github.com/xdevguild/nextjs-dapp-template) - or Nextjs apps +- [useElven](https://www.useelven.com) - React Hooks for interacting with MultiversX blockchain + +If you are interested in creating and managing your own PFP NFT collection, you might be interested in: + +- [Elven Tools](https://www.elven.tools) - What is included: NFT minter smart contract (decentralized way of minting), minter Nextjs dapp (interaction on the frontend side), CLI tool (deploy, configuration, interaction) +- [nft-art-maker](https://github.com/juliancwirko/nft-art-maker) - tool for creating png assets from provided layers. It can also pack files and upload them to IPFS using nft.storage. All CIDs will be auto-updated + +Other tools: + +- [Buildo Begins](https://github.com/xdevguild/buildo-begins) - all MultiversX blockchain CLI interactions with sdk-js, still in progress, but usable +- [Buildo.dev](https://www.buildo.dev) - Buildo.dev is a MultiversX app that helps with blockchain interactions, like issuing tokens and querying smart contracts. diff --git a/packages/elven.js/esbuild.config.js b/packages/elven.js/esbuild.config.js new file mode 100644 index 0000000..87cf477 --- /dev/null +++ b/packages/elven.js/esbuild.config.js @@ -0,0 +1,20 @@ +import { baseConfig } from '@configs/esbuild'; +import * as esbuild from 'esbuild'; +import fs from 'fs'; + +esbuild + .build({ + ...baseConfig, + entryPoints: ['./src/elven.ts'], + }) + .then((result) => { + fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); + return result; + }) + .then((result) => { + return esbuild.analyzeMetafile(result.metafile); + }) + .then((result) => { + fs.writeFileSync('./build/meta.txt', result); + }) + .catch(() => process.exit(1)); diff --git a/packages/elven.js/package.json b/packages/elven.js/package.json new file mode 100644 index 0000000..5a8eaa0 --- /dev/null +++ b/packages/elven.js/package.json @@ -0,0 +1,24 @@ +{ + "name": "elven.js", + "version": "1.0.0", + "description": "Sync, sign and send transactions on the MultiversX blockchain in the browser.", + "type": "module", + "module": "build/elven.js", + "types": "build/types/elven.d.ts", + "exports": { + ".": { + "types": "./build/types/elven.d.ts", + "import": "./build/elven.js", + "browser": "./build/elven.js", + "default": "./build/elven.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "build": "rimraf build && node ./esbuild.config.js && tsc --project ./tsconfig.json && cp build/elven.js ../../demo-app/elven.js", + "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", + "prettier": "prettier --write 'src/**/*.{js,ts,json}'", + "check-types": "tsc --noEmit", + "clean": "rimraf build node_modules" + } +} \ No newline at end of file diff --git a/src/auth/account-sync.ts b/packages/elven.js/src/auth/account-sync.ts similarity index 92% rename from src/auth/account-sync.ts rename to packages/elven.js/src/auth/account-sync.ts index 504be82..795ae1d 100644 --- a/src/auth/account-sync.ts +++ b/packages/elven.js/src/auth/account-sync.ts @@ -6,7 +6,8 @@ import { isLoginExpired } from './expires-at'; export const accountSync = async (elven: any) => { const address = ls.get('address'); const loginExpires = ls.get('expires'); - const loginExpired = loginExpires && isLoginExpired(loginExpires); + const loginExpired = + typeof loginExpires === 'number' ? isLoginExpired(loginExpires) : true; if (!loginExpired && address && elven.networkProvider) { const userAccountInstance = new Account(address); diff --git a/src/auth/expires-at.ts b/packages/elven.js/src/auth/expires-at.ts similarity index 100% rename from src/auth/expires-at.ts rename to packages/elven.js/src/auth/expires-at.ts diff --git a/src/auth/init-extension-provider.ts b/packages/elven.js/src/auth/init-extension-provider.ts similarity index 100% rename from src/auth/init-extension-provider.ts rename to packages/elven.js/src/auth/init-extension-provider.ts diff --git a/src/auth/init-web-wallet-provider.ts b/packages/elven.js/src/auth/init-web-wallet-provider.ts similarity index 100% rename from src/auth/init-web-wallet-provider.ts rename to packages/elven.js/src/auth/init-web-wallet-provider.ts diff --git a/src/auth/login-with-extension.ts b/packages/elven.js/src/auth/login-with-extension.ts similarity index 97% rename from src/auth/login-with-extension.ts rename to packages/elven.js/src/auth/login-with-extension.ts index d857273..d432fb6 100644 --- a/src/auth/login-with-extension.ts +++ b/packages/elven.js/src/auth/login-with-extension.ts @@ -4,7 +4,7 @@ import { errorParse } from '../utils/error-parse'; import { EventStoreEvents, LoginMethodsEnum } from '../types'; import { getNewLoginExpiresTimestamp } from './expires-at'; import { accountSync } from './account-sync'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { NativeAuthClient } from '../core/native-auth-client'; export const loginWithExtension = async ( diff --git a/src/auth/login-with-native-auth-token.ts b/packages/elven.js/src/auth/login-with-native-auth-token.ts similarity index 100% rename from src/auth/login-with-native-auth-token.ts rename to packages/elven.js/src/auth/login-with-native-auth-token.ts diff --git a/src/auth/login-with-web-wallet.ts b/packages/elven.js/src/auth/login-with-web-wallet.ts similarity index 96% rename from src/auth/login-with-web-wallet.ts rename to packages/elven.js/src/auth/login-with-web-wallet.ts index e4922c8..92e3bd7 100644 --- a/src/auth/login-with-web-wallet.ts +++ b/packages/elven.js/src/auth/login-with-web-wallet.ts @@ -4,7 +4,7 @@ import { DAPP_INIT_ROUTE, networkConfig } from '../utils/constants'; import { errorParse } from '../utils/error-parse'; import { ls } from '../utils/ls-helpers'; import { getNewLoginExpiresTimestamp } from './expires-at'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; export const loginWithWebWallet = async ( urlAddress: string, diff --git a/src/auth/logout.ts b/packages/elven.js/src/auth/logout.ts similarity index 93% rename from src/auth/logout.ts rename to packages/elven.js/src/auth/logout.ts index f1a01ac..c7ee5df 100644 --- a/src/auth/logout.ts +++ b/packages/elven.js/src/auth/logout.ts @@ -1,5 +1,5 @@ import { ls } from '../utils/ls-helpers'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { errorParse } from '../utils/error-parse'; diff --git a/packages/elven.js/src/config.ts b/packages/elven.js/src/config.ts new file mode 100644 index 0000000..a615e30 --- /dev/null +++ b/packages/elven.js/src/config.ts @@ -0,0 +1,23 @@ +import { ApiNetworkProvider } from './core/network-provider'; +import { DappProvider, InitOptions, MobileSigningProvider } from './types'; + +export interface ElvenConfig { + initOptions?: InitOptions; + dappProvider?: DappProvider; + networkProvider?: ApiNetworkProvider; + mobileProvider?: MobileSigningProvider; +} + +export const config: ElvenConfig = { + initOptions: undefined, + dappProvider: undefined, + networkProvider: undefined, + mobileProvider: undefined, +}; + +export const resetConfig = () => { + config.initOptions = undefined; + config.dappProvider = undefined; + config.networkProvider = undefined; + config.mobileProvider = undefined; +}; diff --git a/src/core/account.ts b/packages/elven.js/src/core/account.ts similarity index 100% rename from src/core/account.ts rename to packages/elven.js/src/core/account.ts diff --git a/src/core/async-timer.ts b/packages/elven.js/src/core/async-timer.ts similarity index 100% rename from src/core/async-timer.ts rename to packages/elven.js/src/core/async-timer.ts diff --git a/src/core/browser-extension-signing.ts b/packages/elven.js/src/core/browser-extension-signing.ts similarity index 100% rename from src/core/browser-extension-signing.ts rename to packages/elven.js/src/core/browser-extension-signing.ts diff --git a/src/core/constants.ts b/packages/elven.js/src/core/constants.ts similarity index 100% rename from src/core/constants.ts rename to packages/elven.js/src/core/constants.ts diff --git a/src/core/errors.ts b/packages/elven.js/src/core/errors.ts similarity index 100% rename from src/core/errors.ts rename to packages/elven.js/src/core/errors.ts diff --git a/src/core/keccak256.ts b/packages/elven.js/src/core/keccak256.ts similarity index 100% rename from src/core/keccak256.ts rename to packages/elven.js/src/core/keccak256.ts diff --git a/src/core/message.ts b/packages/elven.js/src/core/message.ts similarity index 100% rename from src/core/message.ts rename to packages/elven.js/src/core/message.ts diff --git a/src/core/native-auth-client.ts b/packages/elven.js/src/core/native-auth-client.ts similarity index 68% rename from src/core/native-auth-client.ts rename to packages/elven.js/src/core/native-auth-client.ts index fcdf9e1..bc67b69 100644 --- a/src/core/native-auth-client.ts +++ b/packages/elven.js/src/core/native-auth-client.ts @@ -1,8 +1,6 @@ // Based on Multiversx sdk-core with modifications -import { stringToHex } from './utils'; - -// TODO: review what is really needed regarding the gateway and api fallbacks +import { toBase64FromStringOrBytes } from './utils'; class NativeAuthClientConfig { origin: string = @@ -10,9 +8,8 @@ class NativeAuthClientConfig { ? window.location.hostname : ''; apiUrl: string = 'https://api.multiversx.com'; - expirySeconds: number = 60 * 60 * 24; + expirySeconds: number = 60 * 60 * 2; blockHashShard?: number; - gatewayUrl?: string; extraRequestHeaders?: { [key: string]: string }; } @@ -40,37 +37,9 @@ export class NativeAuthClient { } async getCurrentBlockHash(): Promise { - if (this.config.gatewayUrl) { - return await this.getCurrentBlockHashWithGateway(); - } return await this.getCurrentBlockHashWithApi(); } - private async getCurrentBlockHashWithGateway(): Promise { - const round = await this.getCurrentRound(); - const url = `${this.config.gatewayUrl}/blocks/by-round/${round}`; - const response = await this.get(url); - const blocks = response.data.data.blocks; - const block = blocks.filter( - (block: { shard: number }) => block.shard === this.config.blockHashShard - )[0]; - return block.hash; - } - - private async getCurrentRound(): Promise { - if (!this.config.gatewayUrl) { - throw new Error('Gateway URL not set'); - } - if (!this.config.blockHashShard) { - throw new Error('Blockhash shard not set'); - } - - const url = `${this.config.gatewayUrl}/network/status/${this.config.blockHashShard}`; - const response = await this.get(url); - const status = response.data.data.status; - return status.erd_current_round; - } - private async getCurrentBlockHashWithApi(): Promise { const url = `${this.config.apiUrl}/blocks/latest?ttl=${this.config.expirySeconds}&fields=hash`; const response = await this.get(url); @@ -89,8 +58,9 @@ export class NativeAuthClient { const response = await this.get(url); return response.hash; } + encodeValue(str: string) { - return this.escape(stringToHex(str)); + return this.escape(toBase64FromStringOrBytes(str)); } private escape(str: string) { diff --git a/src/core/network-provider.ts b/packages/elven.js/src/core/network-provider.ts similarity index 100% rename from src/core/network-provider.ts rename to packages/elven.js/src/core/network-provider.ts diff --git a/src/core/transaction-converter.ts b/packages/elven.js/src/core/transaction-converter.ts similarity index 100% rename from src/core/transaction-converter.ts rename to packages/elven.js/src/core/transaction-converter.ts diff --git a/src/core/transaction-status.ts b/packages/elven.js/src/core/transaction-status.ts similarity index 100% rename from src/core/transaction-status.ts rename to packages/elven.js/src/core/transaction-status.ts diff --git a/src/core/transaction-watcher.ts b/packages/elven.js/src/core/transaction-watcher.ts similarity index 100% rename from src/core/transaction-watcher.ts rename to packages/elven.js/src/core/transaction-watcher.ts diff --git a/src/core/transaction.ts b/packages/elven.js/src/core/transaction.ts similarity index 100% rename from src/core/transaction.ts rename to packages/elven.js/src/core/transaction.ts diff --git a/src/core/types.ts b/packages/elven.js/src/core/types.ts similarity index 100% rename from src/core/types.ts rename to packages/elven.js/src/core/types.ts diff --git a/src/core/utils.ts b/packages/elven.js/src/core/utils.ts similarity index 100% rename from src/core/utils.ts rename to packages/elven.js/src/core/utils.ts diff --git a/src/core/web-wallet-signing.ts b/packages/elven.js/src/core/web-wallet-signing.ts similarity index 99% rename from src/core/web-wallet-signing.ts rename to packages/elven.js/src/core/web-wallet-signing.ts index c3ff4fb..bbdb42c 100644 --- a/src/core/web-wallet-signing.ts +++ b/packages/elven.js/src/core/web-wallet-signing.ts @@ -194,7 +194,7 @@ export class WalletProvider { async signTransaction( transaction: Transaction, options?: { callbackUrl?: string } - ): Promise { + ) { await this.signTransactions([transaction], options); } diff --git a/src/core/webview-event-handler.ts b/packages/elven.js/src/core/webview-event-handler.ts similarity index 100% rename from src/core/webview-event-handler.ts rename to packages/elven.js/src/core/webview-event-handler.ts diff --git a/src/core/webview-signing.ts b/packages/elven.js/src/core/webview-signing.ts similarity index 100% rename from src/core/webview-signing.ts rename to packages/elven.js/src/core/webview-signing.ts diff --git a/src/elven.ts b/packages/elven.js/src/elven.ts similarity index 91% rename from src/elven.ts rename to packages/elven.js/src/elven.ts index e5d02a8..f1076fe 100644 --- a/src/elven.ts +++ b/packages/elven.js/src/elven.ts @@ -4,6 +4,6 @@ export { Account } from './core/account'; export { Transaction } from './core/transaction'; export { TransactionWatcher } from './core/transaction-watcher'; -export { ElvenJS } from './main'; +export * from './main'; export { parseAmount, formatAmount } from './utils/amount'; export * from './types'; diff --git a/packages/elven.js/src/events-store.ts b/packages/elven.js/src/events-store.ts new file mode 100644 index 0000000..fdf4b5a --- /dev/null +++ b/packages/elven.js/src/events-store.ts @@ -0,0 +1,22 @@ +import { EventStoreEvents } from './types'; + +let events: Record void> | undefined; + +export function set(name: EventStoreEvents, fn: (...args: any[]) => void) { + if (!name) return; + events = { ...events, [name]: fn }; +} + +export function get(name: EventStoreEvents) { + if (!name || !events) return; + return events[name]; +} + +export function run(name: EventStoreEvents, ...args: any[]) { + if (!name || !events) return; + events[name]?.(...args); +} + +export function clear() { + events = undefined; +} diff --git a/src/initialize-events-store.ts b/packages/elven.js/src/initialize-events-store.ts similarity index 87% rename from src/initialize-events-store.ts rename to packages/elven.js/src/initialize-events-store.ts index 3b43f76..bd2516a 100644 --- a/src/initialize-events-store.ts +++ b/packages/elven.js/src/initialize-events-store.ts @@ -1,4 +1,4 @@ -import { EventsStore } from './events-store'; +import * as EventsStore from './events-store'; import { InitOptions, EventStoreEvents } from './types'; export const initializeEventsStore = (initOptions: InitOptions) => { @@ -37,11 +37,12 @@ export const initializeEventsStore = (initOptions: InitOptions) => { } // Qr code initialization - if (initOptions.onQrPending) { - EventsStore.set(EventStoreEvents.onQrPending, initOptions.onQrPending); + const mobileConfig = initOptions?.externalSigningProviders?.mobile?.config; + if (mobileConfig?.onQrPending) { + EventsStore.set(EventStoreEvents.onQrPending, mobileConfig.onQrPending); } - if (initOptions.onQrLoaded) { - EventsStore.set(EventStoreEvents.onQrLoaded, initOptions.onQrLoaded); + if (mobileConfig?.onQrLoaded) { + EventsStore.set(EventStoreEvents.onQrLoaded, mobileConfig.onQrLoaded); } // Transactions initialization diff --git a/src/interaction/guardian-operations.ts b/packages/elven.js/src/interaction/guardian-operations.ts similarity index 100% rename from src/interaction/guardian-operations.ts rename to packages/elven.js/src/interaction/guardian-operations.ts diff --git a/src/interaction/post-send-tx.ts b/packages/elven.js/src/interaction/post-send-tx.ts similarity index 95% rename from src/interaction/post-send-tx.ts rename to packages/elven.js/src/interaction/post-send-tx.ts index 9ec2cf4..7cd3ec5 100644 --- a/src/interaction/post-send-tx.ts +++ b/packages/elven.js/src/interaction/post-send-tx.ts @@ -2,7 +2,7 @@ import { Account } from '../core/account'; import { TransactionWatcher } from '../core/transaction-watcher'; import { ApiNetworkProvider } from '../core/network-provider'; import { ls } from '../utils/ls-helpers'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { ISentTransactionResponse } from '../core/types'; diff --git a/src/interaction/pre-send-tx.ts b/packages/elven.js/src/interaction/pre-send-tx.ts similarity index 100% rename from src/interaction/pre-send-tx.ts rename to packages/elven.js/src/interaction/pre-send-tx.ts diff --git a/src/interaction/web-wallet-sign-message-finalize.ts b/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts similarity index 92% rename from src/interaction/web-wallet-sign-message-finalize.ts rename to packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts index c08bc98..9dd0592 100644 --- a/src/interaction/web-wallet-sign-message-finalize.ts +++ b/packages/elven.js/src/interaction/web-wallet-sign-message-finalize.ts @@ -1,4 +1,4 @@ -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { getParamFromUrl } from '../utils/get-param-from-url'; diff --git a/src/interaction/web-wallet-tx-finalize.ts b/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts similarity index 98% rename from src/interaction/web-wallet-tx-finalize.ts rename to packages/elven.js/src/interaction/web-wallet-tx-finalize.ts index e3d32fd..9305875 100644 --- a/src/interaction/web-wallet-tx-finalize.ts +++ b/packages/elven.js/src/interaction/web-wallet-tx-finalize.ts @@ -16,7 +16,7 @@ import { import { ApiNetworkProvider } from '../core/network-provider'; import { postSendTx } from './post-send-tx'; import { errorParse } from '../utils/error-parse'; -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { ls } from '../utils/ls-helpers'; import { DAPP_INIT_ROUTE } from '../utils/constants'; import { preSendTx } from './pre-send-tx'; diff --git a/packages/elven.js/src/main.ts b/packages/elven.js/src/main.ts new file mode 100644 index 0000000..b3a4811 --- /dev/null +++ b/packages/elven.js/src/main.ts @@ -0,0 +1,496 @@ +import { Transaction } from './core/transaction'; +import { initExtensionProvider } from './auth/init-extension-provider'; +import { ExtensionProvider } from './core/browser-extension-signing'; +import { WalletProvider } from './core/web-wallet-signing'; +import { NativeAuthClient } from './core/native-auth-client'; +import { WebviewProvider } from './core/webview-signing'; +import { Message } from './core/message'; +import { initWebWalletProvider } from './auth/init-web-wallet-provider'; +import { ls } from './utils/ls-helpers'; +import { + ApiNetworkProvider, + SmartContractQueryArgs, +} from './core/network-provider'; +import { + LoginMethodsEnum, + LoginOptions, + InitOptions, + EventStoreEvents, + MobileSigningProviderDeps, +} from './types'; +import { logout as logoutHelper } from './auth/logout'; +import { loginWithExtension } from './auth/login-with-extension'; +import { loginWithWebWallet } from './auth/login-with-web-wallet'; +import { accountSync } from './auth/account-sync'; +import { errorParse } from './utils/error-parse'; +import { getNewLoginExpiresTimestamp, isLoginExpired } from './auth/expires-at'; +import * as EventsStore from './events-store'; +import { + networkConfig, + defaultApiEndpoint, + defaultChainTypeConfig, +} from './utils/constants'; +import { getParamFromUrl } from './utils/get-param-from-url'; +import { postSendTx } from './interaction/post-send-tx'; +import { webWalletTxFinalize } from './interaction/web-wallet-tx-finalize'; +import { + checkNeedsGuardianSigning, + guardianPreSignTxOperations, + sendTxToGuardian, +} from './interaction/guardian-operations'; +import { preSendTx } from './interaction/pre-send-tx'; +import { webWalletSignMessageFinalize } from './interaction/web-wallet-sign-message-finalize'; +import { loginWithNativeAuthToken } from './auth/login-with-native-auth-token'; +import { initializeEventsStore } from './initialize-events-store'; +import { withLoginEvents } from './utils/with-login-events'; +import { bytesToHex, stringToBytes } from './core/utils'; +import { TransactionsConverter } from './core/transaction-converter'; +import { config, resetConfig } from './config'; + +/** + * Initialization of the Elven.js + */ +export const init = async (options: InitOptions) => { + const state = ls.get(); + + if (state.expires && isLoginExpired(state.expires)) { + ls.clear(); + config.dappProvider = undefined; + return; + } + + config.initOptions = { + chainType: defaultChainTypeConfig, + apiUrl: defaultApiEndpoint, + apiTimeout: 10000, + ...options, + }; + + config.networkProvider = new ApiNetworkProvider(config.initOptions); + + initializeEventsStore(config.initOptions); + + // Initialize the optional mobile provider + const MobileProvider = + config.initOptions?.externalSigningProviders?.mobile?.provider; + if (MobileProvider) { + const deps: MobileSigningProviderDeps = { + networkConfig, + Message, + Transaction, + TransactionsConverter, + ls, + logout: logoutHelper, + getNewLoginExpiresTimestamp, + accountSync, + EventsStore, + }; + const mobileProviderConfig = + config.initOptions?.externalSigningProviders?.mobile?.config; + if (mobileProviderConfig) { + config.mobileProvider = new MobileProvider(mobileProviderConfig, deps); + } else { + throw new Error('Mobile provider config is required!'); + } + } + + // Catch the nativeAuthToken and login with it (for example within xPortal Hub) + const nativeAuthTokenFromUrl = getParamFromUrl('accessToken'); + if (nativeAuthTokenFromUrl) { + await withLoginEvents(async (onLoginSuccess) => { + loginWithNativeAuthToken(nativeAuthTokenFromUrl, config); + await accountSync(config); + onLoginSuccess(); + }); + } + + const isAddress = + state?.address || + ((state.loginMethod === LoginMethodsEnum.webWallet || + state.loginMethod === LoginMethodsEnum.xAlias) && + getParamFromUrl('address')); + + if (isAddress && state?.loginMethod) { + await withLoginEvents(async (onLoginSuccess) => { + if (state.loginMethod === LoginMethodsEnum.browserExtension) { + config.dappProvider = await initExtensionProvider(); + } + if ( + state.loginMethod === LoginMethodsEnum.mobile && + config.mobileProvider + ) { + config.dappProvider = + await config.mobileProvider?.initMobileProvider(config); + } + if (state.loginMethod === LoginMethodsEnum.webview) { + config.dappProvider = new WebviewProvider(); + } + if ( + state.loginMethod === LoginMethodsEnum.webWallet && + config.initOptions?.chainType + ) { + config.dappProvider = await initWebWalletProvider( + networkConfig[config.initOptions.chainType].walletAddress, + config.initOptions.apiUrl + ); + } + if ( + state.loginMethod === LoginMethodsEnum.xAlias && + config.initOptions?.chainType + ) { + config.dappProvider = await initWebWalletProvider( + networkConfig[config.initOptions.chainType].xAliasAddress, + config.initOptions.apiUrl + ); + } + await accountSync(config); + onLoginSuccess(); + }); + + // After successful web wallet transaction (or guarded transaction that use web wallet 2FA hook) we will land back on our website + if (config.initOptions?.chainType) { + // We need to get params from callback url and finalize the transaction + // It will only trigger when there is a WALLET_PROVIDER_CALLBACK_PARAM_TX_SIGNED in url params + await webWalletTxFinalize( + config.dappProvider, + config.networkProvider, + networkConfig[config.initOptions.chainType][ + state.loginMethod === LoginMethodsEnum.xAlias + ? 'xAliasAddress' + : 'walletAddress' + ], + state.nonce + ); + + // We need to get the signature in case of signing a message with web wallet or guardians 2FA hook + webWalletSignMessageFinalize(); + } + } +}; + +/** + * Login function + */ +export const login = async ( + loginMethod: LoginMethodsEnum, + options?: LoginOptions +) => { + const isProperLoginMethod = + Object.values(LoginMethodsEnum).includes(loginMethod); + if (!isProperLoginMethod) { + const error = 'Wrong login method!'; + EventsStore.run(EventStoreEvents.onLoginFailure, error); + throw new Error(error); + } + + if (!config.networkProvider) { + const error = 'Login failed: Use ElvenJs.init() first!'; + EventsStore.run(EventStoreEvents.onLoginFailure, error); + throw new Error(error); + } + + await withLoginEvents(async () => { + // Native auth login token initialization + const nativeAuthClient = new NativeAuthClient({ + apiUrl: config.initOptions?.apiUrl, + origin: window.location.origin, + }); + + const loginToken = await nativeAuthClient.initialize({ + timestamp: `${Math.floor(Date.now() / 1000)}`, + }); + + // Login with browser extension + if (loginMethod === LoginMethodsEnum.browserExtension) { + const dp = await loginWithExtension( + config, + loginToken, + nativeAuthClient, + options?.callbackRoute + ); + config.dappProvider = dp; + } + + // Login with optional mobile provider + if (loginMethod === LoginMethodsEnum.mobile && config.mobileProvider) { + const dp = await config.mobileProvider?.loginWithMobile( + config, + loginToken, + nativeAuthClient + ); + config.dappProvider = dp; + } + + // Login with Web Wallet + if ( + loginMethod === LoginMethodsEnum.webWallet && + config.initOptions?.chainType + ) { + const dp = await loginWithWebWallet( + networkConfig[config.initOptions.chainType].walletAddress, + loginToken, + config.initOptions?.chainType, + options?.callbackRoute + ); + config.dappProvider = dp; + } + + // Login with xAlias + if ( + loginMethod === LoginMethodsEnum.xAlias && + config.initOptions?.chainType + ) { + // Login with xAlias is almost the same as with the web wallet, only endpoints are different + const dp = await loginWithWebWallet( + networkConfig[config.initOptions.chainType].xAliasAddress, + loginToken, + config.initOptions?.chainType, + options?.callbackRoute + ); + config.dappProvider = dp; + } + }); +}; + +/** + * Logout function + */ +export const logout = async () => { + try { + const isLoggedOut = await logoutHelper(config); + config.dappProvider = undefined; + return isLoggedOut; + } catch (e) { + const err = errorParse(e); + console.warn('Something went wrong when logging out: ', err); + } +}; + +/** + * Sign and send function + */ +export const signAndSendTransaction = async (transaction: Transaction) => { + if (!config.dappProvider) { + const error = 'Transaction signing failed: There is no active session!'; + EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); + throw new Error(error); + } + if (!config.networkProvider) { + const error = + 'Transaction signing failed: There is no active network provider!'; + EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); + throw new Error(error); + } + + let signedTx = guardianPreSignTxOperations(transaction); + + try { + EventsStore.run(EventStoreEvents.onTxStart, transaction); + + const currentState = ls.get(); + + transaction.nonce = currentState.nonce; + + if (config.dappProvider instanceof ExtensionProvider) { + signedTx = await config.dappProvider.signTransaction(transaction); + } + if ( + config.mobileProvider && + config.dappProvider instanceof + config.mobileProvider.WalletConnectV2Provider + ) { + signedTx = await config.dappProvider.signTransaction(transaction); + } + if (config.dappProvider instanceof WebviewProvider) { + signedTx = await config.dappProvider.signTransaction(transaction); + } + if (config.dappProvider instanceof WalletProvider) { + await config.dappProvider.signTransaction(transaction); + } + + if ( + currentState.loginMethod !== LoginMethodsEnum.webWallet && + currentState.loginMethod !== LoginMethodsEnum.xAlias + ) { + const needsGuardianSign = checkNeedsGuardianSigning(signedTx); + + if (!needsGuardianSign) { + preSendTx(signedTx); + } + + if (needsGuardianSign && config.initOptions?.chainType) { + await sendTxToGuardian( + signedTx, + networkConfig[config.initOptions.chainType].walletAddress + ); + + return; + } + + const response = await config.networkProvider.sendTransaction(signedTx); + await postSendTx(response, config.networkProvider); + } + } catch (e) { + const err = errorParse(e); + EventsStore.run( + EventStoreEvents.onTxFailure, + signedTx, + `Getting transaction information failed! ${err}` + ); + throw new Error(`Getting transaction information failed! ${err}`); + } + + return signedTx; +}; + +/** + * Sign a single message + */ +export const signMessage = async ( + message: string, + options?: { callbackUrl?: string } +) => { + if (!config.dappProvider) { + const error = 'Message signing failed: There is no active session!'; + EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); + throw new Error(error); + } + if (!config.networkProvider) { + const error = + 'Message signing failed: There is no active network provider!'; + EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); + throw new Error(error); + } + + let messageSignature = ''; + + try { + EventsStore.run(EventStoreEvents.onSignMsgStart, message); + + if (config.dappProvider instanceof ExtensionProvider) { + const signedMessage = await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }) + ); + + if (typeof signedMessage !== 'string' && signedMessage?.signature) { + messageSignature = bytesToHex(signedMessage.signature); + } + } + + if ( + config.mobileProvider && + config.dappProvider instanceof + config.mobileProvider.WalletConnectV2Provider + ) { + const signedMessage = await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }) + ); + + if (typeof signedMessage !== 'string' && signedMessage?.signature) { + messageSignature = bytesToHex(signedMessage.signature); + } + } + + if (config.dappProvider instanceof WebviewProvider) { + const signedMessage = await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }) + ); + + if (typeof signedMessage !== 'string' && signedMessage?.signature) { + messageSignature = bytesToHex(signedMessage.signature); + } + } + if (config.dappProvider instanceof WalletProvider) { + const encodeRFC3986URIComponent = (str: string) => { + return encodeURIComponent(str).replace( + /[!'()*]/g, + (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}` + ); + }; + + const url = options?.callbackUrl || window.location.origin; + await config.dappProvider.signMessage( + new Message({ data: stringToBytes(message) }), + { + callbackUrl: encodeURIComponent( + `${url}${ + url.includes('?') ? '&' : '?' + }message=${encodeRFC3986URIComponent(message)}` + ), + } + ); + } + + const currentState = ls.get(); + + if ( + currentState.loginMethod !== LoginMethodsEnum.webWallet && + currentState.loginMethod !== LoginMethodsEnum.xAlias + ) { + EventsStore.run( + EventStoreEvents.onSignMsgFinalized, + message, + messageSignature + ); + } + + return { message, messageSignature }; + } catch (e) { + const err = errorParse(e); + EventsStore.run(EventStoreEvents.onSignMsgFailure, message, err); + throw new Error(`Message signing failed! ${err}`); + } +}; + +/** + * Query Smart Contracts + */ +export const queryContract = async ({ + address, + func, + args = [], + value = 0, + caller, +}: SmartContractQueryArgs) => { + if (!config.networkProvider) { + throw new Error('Query failed: There is no active network provider!'); + } + + if (!address || !func) { + throw new Error( + 'Query failed: The Query arguments are not valid! Address and func required' + ); + } + + const queryArgs = { + address, + func, + args, + value, + caller, + }; + + try { + EventsStore.run(EventStoreEvents.onQueryStart, queryArgs); + const response = await config.networkProvider.queryContract(queryArgs); + EventsStore.run(EventStoreEvents.onQueryFinalized, response); + return response; + } catch (e) { + const err = errorParse(e); + EventsStore.run(EventStoreEvents.onQueryFinalized, queryArgs, err); + throw new Error(`Smart contract query failed! ${err}`); + } +}; + +/** + * Main storage + */ +export const storage = ls; + +/** + * Destroy and cleanup if needed + */ +export const destroy = () => { + resetConfig(); + EventsStore.clear(); +}; diff --git a/src/types.ts b/packages/elven.js/src/types.ts similarity index 60% rename from src/types.ts rename to packages/elven.js/src/types.ts index 7de4704..2c2548b 100644 --- a/src/types.ts +++ b/packages/elven.js/src/types.ts @@ -1,19 +1,72 @@ import { ExtensionProvider } from './core/browser-extension-signing'; import { Transaction } from './core/transaction'; -import { WalletConnectV2Provider } from './core/walletconnect-signing'; import { WalletProvider } from './core/web-wallet-signing'; import { WebviewProvider } from './core/webview-signing'; import { SmartContractQueryArgs, SmartContractQueryResponse, } from './core/network-provider'; +import { NativeAuthClient } from './core/native-auth-client'; +import { Message } from './core/message'; +import { TransactionsConverter } from './core/transaction-converter'; +import { NetworkType } from './utils/constants'; +import { LocalStorage } from './utils/ls-helpers'; +import * as EventsStore from './events-store'; + +export interface MobileSigningProviderConfig { + walletConnectV2ProjectId: string; + walletConnectV2RelayAddresses: string[]; + qrCodeContainer: string | HTMLElement; + onQrPending: () => void; + onQrLoaded: () => void; +} + +export interface WalletConnectV2Provider + extends Omit { + signTransaction(transaction: Transaction): Promise; +} + +export interface MobileSigningProvider { + initMobileProvider: (elvenJS: any) => Promise; + loginWithMobile: ( + celvenJS: any, + loginToken: string, + nativeAuthClient: NativeAuthClient + ) => Promise; + WalletConnectV2Provider: { + new (...args: any[]): WalletConnectV2Provider; + }; +} + +export type MobileSigningProviderDeps = { + networkConfig: Record; + Message: typeof Message; + Transaction: typeof Transaction; + TransactionsConverter: typeof TransactionsConverter; + ls: LocalStorage; + logout: (instance: any) => Promise; + getNewLoginExpiresTimestamp: () => number; + accountSync: (instance: any) => Promise; + EventsStore: typeof EventsStore; +}; + +export interface MobileProvider { + new ( + config: MobileSigningProviderConfig, + deps: MobileSigningProviderDeps + ): MobileSigningProvider; +} export interface InitOptions { apiUrl?: string; chainType?: string; apiTimeout?: number; - walletConnectV2ProjectId?: string; - walletConnectV2RelayAddresses?: string[]; + externalSigningProviders?: { + mobile?: { + provider: MobileProvider; + config: MobileSigningProviderConfig; + }; + }; // Login onLoginStart?: () => void; onLoginSuccess?: () => void; @@ -22,9 +75,6 @@ export interface InitOptions { onLogoutStart?: () => void; onLogoutSuccess?: () => void; onLogoutFailure?: (error: string) => void; - // Qr - onQrPending?: () => void; - onQrLoaded?: () => void; // Transaction onTxStart?: (transaction: Transaction) => void; onTxSent?: (transaction: Transaction) => void; @@ -78,7 +128,6 @@ export enum LoginMethodsEnum { export type DappProvider = | ExtensionProvider - | WalletConnectV2Provider | WalletProvider | WebviewProvider | undefined; diff --git a/src/utils/amount.ts b/packages/elven.js/src/utils/amount.ts similarity index 100% rename from src/utils/amount.ts rename to packages/elven.js/src/utils/amount.ts diff --git a/src/utils/constants.ts b/packages/elven.js/src/utils/constants.ts similarity index 98% rename from src/utils/constants.ts rename to packages/elven.js/src/utils/constants.ts index 66b09b7..1e1b352 100644 --- a/src/utils/constants.ts +++ b/packages/elven.js/src/utils/constants.ts @@ -1,4 +1,4 @@ -interface NetworkType { +export interface NetworkType { id: string; shortId: string; name: string; diff --git a/src/utils/error-parse.ts b/packages/elven.js/src/utils/error-parse.ts similarity index 100% rename from src/utils/error-parse.ts rename to packages/elven.js/src/utils/error-parse.ts diff --git a/src/utils/get-param-from-url.ts b/packages/elven.js/src/utils/get-param-from-url.ts similarity index 100% rename from src/utils/get-param-from-url.ts rename to packages/elven.js/src/utils/get-param-from-url.ts diff --git a/src/utils/get-random-address-from-network.ts b/packages/elven.js/src/utils/get-random-address-from-network.ts similarity index 100% rename from src/utils/get-random-address-from-network.ts rename to packages/elven.js/src/utils/get-random-address-from-network.ts diff --git a/src/utils/ls-helpers.ts b/packages/elven.js/src/utils/ls-helpers.ts similarity index 78% rename from src/utils/ls-helpers.ts rename to packages/elven.js/src/utils/ls-helpers.ts index eec4e6c..ccbdaa8 100644 --- a/src/utils/ls-helpers.ts +++ b/packages/elven.js/src/utils/ls-helpers.ts @@ -1,7 +1,13 @@ import { LOCAL_STORAGE_KEY } from './constants'; +export interface LocalStorage { + get(key?: string): any; + set(key: string, value: string | number): void; + clear(): void; +} + // Local storage helpers for the Elven.js key -export const ls = { +export const ls: LocalStorage = { get(key?: string) { const state = localStorage.getItem(LOCAL_STORAGE_KEY); if (!state) return {}; diff --git a/src/utils/with-login-events.ts b/packages/elven.js/src/utils/with-login-events.ts similarity index 91% rename from src/utils/with-login-events.ts rename to packages/elven.js/src/utils/with-login-events.ts index 915d3bc..6eb393a 100644 --- a/src/utils/with-login-events.ts +++ b/packages/elven.js/src/utils/with-login-events.ts @@ -1,4 +1,4 @@ -import { EventsStore } from '../events-store'; +import * as EventsStore from '../events-store'; import { EventStoreEvents } from '../types'; import { errorParse } from './error-parse'; diff --git a/src/webview-provider/base64-utils.ts b/packages/elven.js/src/webview-provider/base64-utils.ts similarity index 100% rename from src/webview-provider/base64-utils.ts rename to packages/elven.js/src/webview-provider/base64-utils.ts diff --git a/src/webview-provider/decode-login-token.ts b/packages/elven.js/src/webview-provider/decode-login-token.ts similarity index 100% rename from src/webview-provider/decode-login-token.ts rename to packages/elven.js/src/webview-provider/decode-login-token.ts diff --git a/src/webview-provider/decode-native-auth-token.ts b/packages/elven.js/src/webview-provider/decode-native-auth-token.ts similarity index 100% rename from src/webview-provider/decode-native-auth-token.ts rename to packages/elven.js/src/webview-provider/decode-native-auth-token.ts diff --git a/src/webview-provider/utils.ts b/packages/elven.js/src/webview-provider/utils.ts similarity index 100% rename from src/webview-provider/utils.ts rename to packages/elven.js/src/webview-provider/utils.ts diff --git a/packages/elven.js/tsconfig.json b/packages/elven.js/tsconfig.json new file mode 100644 index 0000000..1c1f647 --- /dev/null +++ b/packages/elven.js/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "declarationDir": "./build/types", + "outDir": "./build" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "build"] +} diff --git a/packages/mobile-signing-provider/CHANGELOG.md b/packages/mobile-signing-provider/CHANGELOG.md new file mode 100644 index 0000000..802ac1f --- /dev/null +++ b/packages/mobile-signing-provider/CHANGELOG.md @@ -0,0 +1 @@ +## TODO diff --git a/packages/mobile-signing-provider/README.md b/packages/mobile-signing-provider/README.md new file mode 100644 index 0000000..802ac1f --- /dev/null +++ b/packages/mobile-signing-provider/README.md @@ -0,0 +1 @@ +## TODO diff --git a/packages/mobile-signing-provider/esbuild.config.js b/packages/mobile-signing-provider/esbuild.config.js new file mode 100644 index 0000000..3eaa9c8 --- /dev/null +++ b/packages/mobile-signing-provider/esbuild.config.js @@ -0,0 +1,20 @@ +import { baseConfig } from '@configs/esbuild'; +import * as esbuild from 'esbuild'; +import fs from 'fs'; + +esbuild + .build({ + ...baseConfig, + entryPoints: ['./src/mobile-signing-provider.ts'], + }) + .then((result) => { + fs.writeFileSync('./build/meta.json', JSON.stringify(result.metafile)); + return result; + }) + .then((result) => { + return esbuild.analyzeMetafile(result.metafile); + }) + .then((result) => { + fs.writeFileSync('./build/meta.txt', result); + }) + .catch(() => process.exit(1)); diff --git a/packages/mobile-signing-provider/package.json b/packages/mobile-signing-provider/package.json new file mode 100644 index 0000000..0ee0d44 --- /dev/null +++ b/packages/mobile-signing-provider/package.json @@ -0,0 +1,33 @@ +{ + "name": "@elven.js/mobile-signing-provider", + "version": "1.0.0", + "description": "Mobile signing provider for Elven.js.", + "type": "module", + "module": "build/mobile-signing-provider.js", + "types": "build/types/mobile-signing-provider.d.ts", + "exports": { + ".": { + "types": "./build/types/mobile-signing-provider.d.ts", + "import": "./build/mobile-signing-provider.js", + "browser": "./build/mobile-signing-provider.js", + "default": "./build/mobile-signing-provider.js" + }, + "./package.json": "./package.json" + }, + "scripts": { + "build": "rimraf build && node ./esbuild.config.js && tsc && cp build/mobile-signing-provider.js ../../demo-app/mobile-signing-provider.js", + "lint": "eslint \"src/**/*.{ts,tsx,js,jsx}\" --fix", + "prettier": "prettier --write 'src/**/*.{js,ts,json}'", + "check-types": "tsc --noEmit", + "clean": "rimraf build node_modules" + }, + "devDependencies": { + "@walletconnect/sign-client": "2.17.2", + "@walletconnect/types": "2.17.2", + "@walletconnect/utils": "2.17.2", + "uqr": "0.1.2" + }, + "peerDependencies": { + "elven.js": "*" + } +} \ No newline at end of file diff --git a/packages/mobile-signing-provider/src/components/constants.ts b/packages/mobile-signing-provider/src/components/constants.ts new file mode 100644 index 0000000..b39e794 --- /dev/null +++ b/packages/mobile-signing-provider/src/components/constants.ts @@ -0,0 +1,7 @@ +export const WALLETCONNECT_MULTIVERSX_METHODS = [ + 'mvx_signTransaction', + 'mvx_signTransactions', + 'mvx_signMessage', +]; +export const WALLETCONNECT_MULTIVERSX_NAMESPACE = 'mvx'; +export const WALLETCONNECT_SIGN_LOGIN_DELAY = 500; diff --git a/src/auth/qr-code-and-pairings-builder.ts b/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts similarity index 92% rename from src/auth/qr-code-and-pairings-builder.ts rename to packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts index 9754a05..ec2e336 100644 --- a/src/auth/qr-code-and-pairings-builder.ts +++ b/packages/mobile-signing-provider/src/components/qr-code-and-pairings-builder.ts @@ -1,11 +1,8 @@ -import { toString } from 'qrcode'; -import { - WalletConnectV2Provider, - PairingTypes, -} from '../core/walletconnect-signing'; -import { walletConnectDeepLink } from '../utils/constants'; -import { errorParse } from '../utils/error-parse'; -import { DappProvider, DappCoreWCV2CustomMethodsEnum } from '../types'; +import { renderSVG } from 'uqr'; +import { WalletConnectV2Provider, PairingTypes } from './walletconnect-signing'; +import { walletConnectDeepLink } from './utils'; +import { errorParse } from './utils'; +import { DappCoreWCV2CustomMethodsEnum } from './types'; const htmlStringToElement = (htmlString: string) => { const template = document.createElement('template'); @@ -119,22 +116,20 @@ const isMobile = () => navigator.userAgent ); -const generateQRCode = async (walletConnectUri: string) => { +const generateQRCode = (walletConnectUri: string) => { if (!walletConnectUri) { return; } - const svg = await toString(walletConnectUri, { - type: 'svg', - }); + const qrCode = renderSVG(walletConnectUri); - return svg; + return qrCode; }; export const qrCodeAndPairingsBuilder = async ( qrCodeContainer: string | HTMLElement, walletConnectUri: string, - dappProvider: DappProvider, + dappProvider: any, token?: string ) => { if (!qrCodeContainer) @@ -150,7 +145,7 @@ export const qrCodeAndPairingsBuilder = async ( containerElem = qrCodeContainer; } - const qrCodeElementString = await generateQRCode(walletConnectUri); + const qrCodeElementString = generateQRCode(walletConnectUri); // QRCode diff --git a/packages/mobile-signing-provider/src/components/types.ts b/packages/mobile-signing-provider/src/components/types.ts new file mode 100644 index 0000000..a57e5e6 --- /dev/null +++ b/packages/mobile-signing-provider/src/components/types.ts @@ -0,0 +1,89 @@ +export enum EventStoreEvents { + // Login + onLoginStart = 'onLoginStart', + onLoginSuccess = 'onLoginSuccess', + onLoginFailure = 'onLoginFailure', + // Logout + onLogoutStart = 'onLogoutStart', + onLogoutSuccess = 'onLogoutSuccess', + onLogoutFailure = 'onLogoutFailure', + // Qr + onQrPending = 'onQrPending', + onQrLoaded = 'onQrLoaded', + // Transaction + onTxStart = 'onTxStart', + onTxSent = 'onTxSent', + onTxFinalized = 'onTxFinalized', + onTxFailure = 'onTxFailure', + // Signing + onSignMsgStart = 'onSignMsgStart', + onSignMsgFinalized = 'onSignMsgFinalized', + onSignMsgFailure = 'onSignMsgFailure', + // Query + onQueryStart = 'onQueryStart', + onQueryFinalized = 'onQueryFinalized', + onQueryFailure = 'onQueryFailure', +} + +export enum LoginMethodsEnum { + ledger = 'ledger', + mobile = 'mobile', + webWallet = 'web-wallet', + browserExtension = 'browser-extension', + xAlias = 'x-alias', + webview = 'webview', +} + +export enum DappCoreWCV2CustomMethodsEnum { + mvx_cancelAction = 'mvx_cancelAction', + mvx_signNativeAuthToken = 'mvx_signNativeAuthToken', +} + +export enum WalletConnectV2ProviderErrorMessagesEnum { + unableToInit = 'WalletConnect is unable to init', + notInitialized = 'WalletConnect is not initialized', + unableToConnect = 'WalletConnect is unable to connect', + unableToConnectExisting = 'WalletConnect is unable to connect to existing pairing', + unableToSignLoginToken = 'WalletConnect could not sign login token', + unableToSign = 'WalletConnect could not sign the message', + unableToLogin = 'WalletConnect is unable to login', + unableToHandleTopic = 'WalletConnect: Unable to handle topic update', + unableToHandleEvent = 'WalletConnect: Unable to handle events', + unableToHandleCleanup = 'WalletConnect: Unable to handle cleanup', + sessionNotConnected = 'WalletConnect Session is not connected', + sessionDeleted = 'WalletConnect Session Deleted', + sessionExpired = 'WalletConnect Session Expired', + alreadyLoggedOut = 'WalletConnect: Already logged out', + pingFailed = 'WalletConnect Ping Failed', + invalidAddress = 'WalletConnect: Invalid address', + requestDifferentChain = 'WalletConnect: Request Chain Id different than Connection Chain Id', + invalidMessageResponse = 'WalletConnect could not sign the message: invalid message response', + invalidMessageSignature = 'WalletConnect: Invalid message signature', + invalidTransactionResponse = 'WalletConnect could not sign the transactions. Invalid signatures', + invalidCustomRequestResponse = 'WalletConnect could not send the custom request', + transactionError = 'Transaction canceled', + connectionError = 'WalletConnect could not establish a connection', + invalidGuardian = 'WalletConnect: Invalid Guardian', +} + +export interface Context { + networkProvider?: unknown; + initOptions: { chainType: string }; + dappProvider?: unknown; +} + +export interface NativeAuthClient { + getToken(address: string, loginToken: string, signature: string): string; +} + +export interface LocalStorage { + set(key: string, value: unknown): void; +} + +export interface EventsStore { + run(event: string, ...args: unknown[]): void; +} + +export interface NetworkConfig { + [key: string]: { shortId: string }; +} diff --git a/packages/mobile-signing-provider/src/components/utils.ts b/packages/mobile-signing-provider/src/components/utils.ts new file mode 100644 index 0000000..13512cc --- /dev/null +++ b/packages/mobile-signing-provider/src/components/utils.ts @@ -0,0 +1,26 @@ +export const errorParse = (err: unknown) => { + if (typeof err === 'string') { + return err.toUpperCase(); + } else if (err instanceof Error) { + return err.message; + } + return JSON.stringify(err); +}; + +export function getRandomAddressFromNetwork(addresses: string[]) { + return addresses[Math.floor(Math.random() * addresses.length)]; +} + +export const walletConnectDeepLink = + 'https://maiar.page.link/?apn=com.elrond.maiar.wallet&isi=1519405832&ibi=com.elrond.maiar.wallet&link=https://xportal.com/'; + +export const hexToBytes = (hex: string): Uint8Array => { + if (!/^[0-9a-fA-F]+$/.test(hex) || hex.length % 2 !== 0) { + throw new Error('Invalid hex string'); + } + const bytes = new Uint8Array(hex.length / 2); + for (let i = 0; i < bytes.length; i++) { + bytes[i] = parseInt(hex.substr(i * 2, 2), 16); + } + return bytes; +}; diff --git a/src/core/walletconnect-signing.ts b/packages/mobile-signing-provider/src/components/walletconnect-signing.ts similarity index 96% rename from src/core/walletconnect-signing.ts rename to packages/mobile-signing-provider/src/components/walletconnect-signing.ts index 590a1ae..4bfeb3e 100644 --- a/src/core/walletconnect-signing.ts +++ b/packages/mobile-signing-provider/src/components/walletconnect-signing.ts @@ -1,7 +1,5 @@ // Based on Multiversx sdk WalletConnect signing provider with modifications -import { Message } from './message'; -import { Transaction } from './transaction'; import Client from '@walletconnect/sign-client'; import { EngineTypes, @@ -10,11 +8,6 @@ import { SignClientTypes, } from '@walletconnect/types'; import { getSdkError, isValidArray } from '@walletconnect/utils'; -import { - WALLETCONNECT_MULTIVERSX_NAMESPACE, - WALLETCONNECT_SIGN_LOGIN_DELAY, -} from './constants'; -import { WalletConnectV2ProviderErrorMessagesEnum } from './types'; import { applyTransactionSignature, addressIsValid, @@ -27,7 +20,12 @@ import { TransactionResponse, sleep, } from './walletconnect-utils'; -import { TransactionsConverter } from './transaction-converter'; + +import { + WALLETCONNECT_MULTIVERSX_NAMESPACE, + WALLETCONNECT_SIGN_LOGIN_DELAY, +} from './constants'; +import { WalletConnectV2ProviderErrorMessagesEnum } from './types'; enum Operation { SIGN_TRANSACTION = 'mvx_signTransaction', @@ -81,6 +79,9 @@ export class WalletConnectV2Provider { pairings: PairingTypes.Struct[] | undefined; processingTopic: string = ''; options: SignClientTypes.Options | undefined = {}; + Message: any; + Transaction: any; + TransactionsConverter: any; private onClientConnect: IClientConnect; private account: IProviderAccount = { address: '' }; @@ -90,12 +91,18 @@ export class WalletConnectV2Provider { chainId: string, walletConnectV2Relay: string, walletConnectV2ProjectId: string, + Message: any, + Transaction: any, + TransactionsConverter: any, options?: SignClientTypes.Options ) { this.onClientConnect = onClientConnect; this.chainId = chainId; this.walletConnectV2Relay = walletConnectV2Relay; this.walletConnectV2ProjectId = walletConnectV2ProjectId; + this.Message = Message; + this.Transaction = Transaction; + this.TransactionsConverter = TransactionsConverter; this.options = options; } @@ -385,8 +392,10 @@ export class WalletConnectV2Provider { * Signs a message and returns it signed * @param message */ - async signMessage(messageToSign: Message): Promise { - const message = new Message({ + async signMessage( + messageToSign: typeof this.Message + ): Promise { + const message = new this.Message({ data: Buffer.from(messageToSign.data), address: messageToSign.address ?? this.account.address, signer: 'wallet-connect-v2', @@ -453,7 +462,9 @@ export class WalletConnectV2Provider { * Signs a transaction and returns it signed * @param transaction */ - async signTransaction(transaction: Transaction): Promise { + async signTransaction( + transaction: typeof this.Transaction + ): Promise { if (typeof this.walletConnector === 'undefined') { console.error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); throw new Error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); @@ -470,7 +481,7 @@ export class WalletConnectV2Provider { } const plainTransaction = - TransactionsConverter.transactionToPlainObject(transaction); + this.TransactionsConverter.transactionToPlainObject(transaction); if (this.chainId !== transaction.chainID) { console.error( @@ -505,7 +516,9 @@ export class WalletConnectV2Provider { * Signs an array of transactions and returns it signed * @param transactions */ - async signTransactions(transactions: Transaction[]): Promise { + async signTransactions( + transactions: (typeof this.Transaction)[] + ): Promise<(typeof this.Transaction)[]> { if (typeof this.walletConnector === 'undefined') { console.error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); throw new Error(WalletConnectV2ProviderErrorMessagesEnum.notInitialized); @@ -530,7 +543,7 @@ export class WalletConnectV2Provider { WalletConnectV2ProviderErrorMessagesEnum.requestDifferentChain ); } - return TransactionsConverter.transactionToPlainObject(transaction); + return this.TransactionsConverter.transactionToPlainObject(transaction); }); try { diff --git a/src/core/walletconnect-utils.ts b/packages/mobile-signing-provider/src/components/walletconnect-utils.ts similarity index 98% rename from src/core/walletconnect-utils.ts rename to packages/mobile-signing-provider/src/components/walletconnect-utils.ts index 219cd1c..0576ecc 100644 --- a/src/core/walletconnect-utils.ts +++ b/packages/mobile-signing-provider/src/components/walletconnect-utils.ts @@ -1,6 +1,5 @@ // Based on Multiversx sdk WalletConnect signing provider with modifications -import { Transaction } from './transaction'; import Client from '@walletconnect/sign-client'; import { getAppMetadata } from '@walletconnect/utils'; import { @@ -133,9 +132,9 @@ export function applyTransactionSignature({ transaction, response, }: { - transaction: Transaction; + transaction: any; response: TransactionResponse; -}): Transaction { +}): any { if (!response) { console.log( WalletConnectV2ProviderErrorMessagesEnum.invalidTransactionResponse diff --git a/packages/mobile-signing-provider/src/mobile-signing-provider.ts b/packages/mobile-signing-provider/src/mobile-signing-provider.ts new file mode 100644 index 0000000..b75afe2 --- /dev/null +++ b/packages/mobile-signing-provider/src/mobile-signing-provider.ts @@ -0,0 +1,234 @@ +import { + SessionEventTypes, + WalletConnectV2Provider, +} from './components/walletconnect-signing'; +import { + Context, + NetworkConfig, + NativeAuthClient, + LocalStorage, + EventsStore, + EventStoreEvents, + DappCoreWCV2CustomMethodsEnum, + LoginMethodsEnum, +} from './components/types'; + +import { errorParse, getRandomAddressFromNetwork } from './components/utils'; +import { qrCodeAndPairingsBuilder } from './components/qr-code-and-pairings-builder'; + +export class MobileSigningProvider { + private walletConnectV2ProjectId: string; + private walletConnectV2RelayAddresses: string[]; + private qrCodeContainer: string | HTMLElement; + private networkConfig: NetworkConfig; + private Message: new (...args: any[]) => unknown; + private Transaction: new (...args: any[]) => unknown; + private TransactionsConverter: new (...args: any[]) => unknown; + private ls: LocalStorage; + private logout: (context: Context) => Promise; + private getNewLoginExpiresTimestamp: () => number; + private accountSync: (context: Context) => Promise; + private EventsStore: EventsStore; + + WalletConnectV2Provider = WalletConnectV2Provider; + + constructor( + { + walletConnectV2ProjectId, + walletConnectV2RelayAddresses, + qrCodeContainer, + }: { + walletConnectV2ProjectId: string; + walletConnectV2RelayAddresses: string[]; + qrCodeContainer: string | HTMLElement; + }, + deps: { + networkConfig: NetworkConfig; + Message: new (...args: any[]) => unknown; + Transaction: new (...args: any[]) => unknown; + TransactionsConverter: new (...args: any[]) => unknown; + ls: LocalStorage; + logout: (context: Context) => Promise; + getNewLoginExpiresTimestamp: () => number; + accountSync: (context: Context) => Promise; + EventsStore: EventsStore; + } + ) { + this.walletConnectV2ProjectId = walletConnectV2ProjectId; + this.walletConnectV2RelayAddresses = walletConnectV2RelayAddresses; + this.qrCodeContainer = qrCodeContainer; + this.networkConfig = deps.networkConfig; + this.Message = deps.Message; + this.Transaction = deps.Transaction; + this.TransactionsConverter = deps.TransactionsConverter; + this.ls = deps.ls; + this.logout = deps.logout; + this.getNewLoginExpiresTimestamp = deps.getNewLoginExpiresTimestamp; + this.accountSync = deps.accountSync; + this.EventsStore = deps.EventsStore; + } + + initMobileProvider = async (context: Context) => { + if (!this.walletConnectV2ProjectId || !context.initOptions.chainType) { + return undefined; + } + + const providerHandlers = { + onClientLogin: () => {}, + onClientLogout: () => this.logout(context), + onClientEvent: (event: SessionEventTypes['event']) => { + console.log('wc2 session event: ', event); + }, + }; + + const relayAddress = getRandomAddressFromNetwork( + this.walletConnectV2RelayAddresses + ); + + const dappProviderInstance = new WalletConnectV2Provider( + providerHandlers, + this.networkConfig[context.initOptions.chainType].shortId, + relayAddress, + this.walletConnectV2ProjectId, + this.Message, + this.Transaction, + this.TransactionsConverter + ); + + try { + await dappProviderInstance.init(); + return dappProviderInstance; + } catch { + console.warn("Can't initialize the Dapp Provider!"); + return undefined; + } + }; + + loginWithMobile = async ( + context: Context, + loginToken: string, + nativeAuthClient: NativeAuthClient + ) => { + if (!this.qrCodeContainer) { + throw new Error( + "You haven't provided the QR code container DOM element id" + ); + } + + const relayAddress = getRandomAddressFromNetwork( + this.walletConnectV2RelayAddresses + ); + + if (!relayAddress || !context.networkProvider) { + throw new Error( + "Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!" + ); + } + + if (!this.walletConnectV2ProjectId) { + throw new Error( + 'Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)' + ); + } + + if (!context.initOptions.chainType) { + throw new Error( + 'Please provide the chain type in ElvenJS.init function!' + ); + } + + let qrCodeElement: HTMLElement | null; + + const providerHandlers = { + onClientLogin: async () => { + if (context.dappProvider instanceof WalletConnectV2Provider) { + const address = context.dappProvider.getAddress(); + const signature = context.dappProvider.getSignature(); + + this.ls.set('address', address); + this.ls.set('loginMethod', LoginMethodsEnum.mobile); + this.ls.set('expires', this.getNewLoginExpiresTimestamp()); + + await this.accountSync(context); + + if (signature) { + this.ls.set('signature', signature); + this.ls.set('loginToken', loginToken); + + const accessToken = nativeAuthClient.getToken( + address, + loginToken, + signature + ); + + this.ls.set('accessToken', accessToken); + + this.EventsStore.run(EventStoreEvents.onLoginSuccess); + qrCodeElement?.replaceChildren(); + } + } + }, + onClientLogout: async () => { + if (context.dappProvider instanceof WalletConnectV2Provider) { + await this.logout(context); + } + }, + onClientEvent: (event: SessionEventTypes['event']) => { + console.log('wc2 session event: ', event); + }, + }; + + const dappProvider = new WalletConnectV2Provider( + providerHandlers, + this.networkConfig[context.initOptions.chainType].shortId, + relayAddress, + this.walletConnectV2ProjectId, + this.Message, + this.Transaction, + this.TransactionsConverter + ); + + try { + if (dappProvider) { + context.dappProvider = dappProvider; + + this.EventsStore.run(EventStoreEvents.onQrPending); + + await dappProvider.init(); + + const { uri: walletConnectUri, approval } = await dappProvider.connect({ + methods: [ + DappCoreWCV2CustomMethodsEnum.mvx_cancelAction, + DappCoreWCV2CustomMethodsEnum.mvx_signNativeAuthToken, + ], + }); + + const wCUri = loginToken + ? `${walletConnectUri}&token=${loginToken}` + : walletConnectUri; + + if (this.qrCodeContainer && wCUri) { + qrCodeElement = await qrCodeAndPairingsBuilder( + this.qrCodeContainer, + wCUri, + dappProvider, + loginToken + ); + + this.EventsStore.run(EventStoreEvents.onQrLoaded); + } + + await dappProvider.login({ + approval, + token: loginToken, + }); + + return dappProvider; + } + } catch (e) { + const err = errorParse(e); + console.warn(`Something went wrong trying to login the user: ${err}`); + this.EventsStore.run(EventStoreEvents.onLoginFailure, err); + } + }; +} diff --git a/packages/mobile-signing-provider/tsconfig.json b/packages/mobile-signing-provider/tsconfig.json new file mode 100644 index 0000000..1c1f647 --- /dev/null +++ b/packages/mobile-signing-provider/tsconfig.json @@ -0,0 +1,9 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "declarationDir": "./build/types", + "outDir": "./build" + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "build"] +} diff --git a/src/auth/init-mobile-provider.ts b/src/auth/init-mobile-provider.ts deleted file mode 100644 index 7bfbad2..0000000 --- a/src/auth/init-mobile-provider.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { - SessionEventTypes, - WalletConnectV2Provider, -} from '../core/walletconnect-signing'; -import { networkConfig } from '../utils/constants'; -import { logout } from './logout'; -import { getRandomAddressFromNetwork } from '../utils/get-random-address-from-network'; - -export const initMobileProvider = async (elven: any) => { - if ( - !elven.initOptions.walletConnectV2ProjectId || - !elven.initOptions.chainType - ) { - return undefined; - } - - const providerHandlers = { - onClientLogin: () => {}, - onClientLogout: () => logout(elven), - onClientEvent: (event: SessionEventTypes['event']) => { - console.log('wc2 session event: ', event); - }, - }; - - const relayAddress = getRandomAddressFromNetwork( - elven.initOptions.walletConnectV2RelayAddresses - ); - - const dappProviderInstance = new WalletConnectV2Provider( - providerHandlers, - networkConfig[elven.initOptions.chainType].shortId, - relayAddress, - elven.initOptions.walletConnectV2ProjectId - ); - - try { - await dappProviderInstance.init(); - return dappProviderInstance; - } catch { - console.warn("Can't initialize the Dapp Provider!"); - } -}; diff --git a/src/auth/login-with-mobile.ts b/src/auth/login-with-mobile.ts deleted file mode 100644 index f6646fc..0000000 --- a/src/auth/login-with-mobile.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { errorParse } from '../utils/error-parse'; -import { qrCodeAndPairingsBuilder } from './qr-code-and-pairings-builder'; -import { networkConfig } from '../utils/constants'; -import { getRandomAddressFromNetwork } from '../utils/get-random-address-from-network'; -import { - WalletConnectV2Provider, - SessionEventTypes, -} from '../core/walletconnect-signing'; -import { EventStoreEvents, LoginMethodsEnum } from '../types'; -import { ls } from '../utils/ls-helpers'; -import { logout } from './logout'; -import { getNewLoginExpiresTimestamp } from './expires-at'; -import { accountSync } from './account-sync'; -import { EventsStore } from '../events-store'; -import { DappCoreWCV2CustomMethodsEnum } from '../types'; -import { NativeAuthClient } from '../core/native-auth-client'; - -export const loginWithMobile = async ( - elven: any, - loginToken: string, - nativeAuthClient: NativeAuthClient, - qrCodeContainer?: string | HTMLElement -) => { - if (!qrCodeContainer) { - throw new Error( - "You haven't provided the QR code container DOM element id" - ); - } - - const relayAddress = getRandomAddressFromNetwork( - elven.initOptions.walletConnectV2RelayAddresses - ); - - if (!relayAddress || !elven.networkProvider) { - throw new Error( - "Something wen't wrong with the initialization (ApiNetworkProvider or Wallet Connect Bridge address), plese try to refresh the page!" - ); - } - - if (!elven.initOptions.walletConnectV2ProjectId) { - throw new Error( - 'Please provide your WalletConnect project id. You can get it here: https://cloud.walletconnect.com)' - ); - } - - if (!elven.initOptions.chainType) { - throw new Error('Please provide the chain type in ElvenJS.init function!'); - } - - let qrCodeElement: HTMLElement | null; - - const providerHandlers = { - onClientLogin: async () => { - if (elven.dappProvider instanceof WalletConnectV2Provider) { - const address = await elven.dappProvider.getAddress(); - const signature = await elven.dappProvider.getSignature(); - - ls.set('address', address); - ls.set('loginMethod', LoginMethodsEnum.mobile); - ls.set('expires', getNewLoginExpiresTimestamp()); - - await accountSync(elven); - - if (signature) { - ls.set('signature', signature); - } - - ls.set('loginToken', loginToken); - - const accessToken = nativeAuthClient.getToken( - address, - loginToken, - signature - ); - ls.set('accessToken', accessToken); - - EventsStore.run(EventStoreEvents.onLoginSuccess); - qrCodeElement?.replaceChildren(); - } - }, - onClientLogout: async () => { - if (elven.dappProvider instanceof WalletConnectV2Provider) { - await logout(elven); - } - }, - onClientEvent: (event: SessionEventTypes['event']) => { - console.log('wc2 session event: ', event); - }, - }; - - const dappProvider = new WalletConnectV2Provider( - providerHandlers, - networkConfig[elven.initOptions.chainType].shortId, - relayAddress, - elven.initOptions.walletConnectV2ProjectId - ); - - try { - if (dappProvider) { - elven.dappProvider = dappProvider; - - EventsStore.run(EventStoreEvents.onQrPending); - - await dappProvider.init(); - - const { uri: walletConnectUri, approval } = await dappProvider.connect({ - methods: [ - DappCoreWCV2CustomMethodsEnum.mvx_cancelAction, - DappCoreWCV2CustomMethodsEnum.mvx_signNativeAuthToken, - ], - }); - - const wCUri = loginToken - ? `${walletConnectUri}&token=${loginToken}` - : walletConnectUri; - - if (qrCodeContainer && wCUri) { - qrCodeElement = await qrCodeAndPairingsBuilder( - qrCodeContainer, - wCUri, - dappProvider, - loginToken - ); - - EventsStore.run(EventStoreEvents.onQrLoaded); - } - - await dappProvider.login({ - approval, - token: loginToken, - }); - - return dappProvider; - } - } catch (e) { - const err = errorParse(e); - console.warn(`Something went wrong trying to login the user: ${err}`); - EventsStore.run(EventStoreEvents.onLoginFailure, err); - } -}; diff --git a/src/events-store.ts b/src/events-store.ts deleted file mode 100644 index f42955b..0000000 --- a/src/events-store.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { EventStoreEvents } from './types'; - -export class EventsStore { - private static events: Record void> | undefined; - - static set(name: EventStoreEvents, fn: (...args: any[]) => void) { - if (!name) return; - const eventsObj = { ...this.events, [name]: fn }; - this.events = eventsObj; - } - - static get(name: EventStoreEvents) { - if (!name || !this.events) return; - return this.events[name]; - } - - static run(name: EventStoreEvents, ...args: any[]) { - if (!name || !this.events) return; - this.events[name]?.(...args); - } - - static clear() { - this.events = undefined; - } -} diff --git a/src/main.ts b/src/main.ts deleted file mode 100644 index 2f11373..0000000 --- a/src/main.ts +++ /dev/null @@ -1,467 +0,0 @@ -import { Transaction } from './core/transaction'; -import { initExtensionProvider } from './auth/init-extension-provider'; -import { ExtensionProvider } from './core/browser-extension-signing'; -import { WalletConnectV2Provider } from './core/walletconnect-signing'; -import { WalletProvider } from './core/web-wallet-signing'; -import { NativeAuthClient } from './core/native-auth-client'; -import { WebviewProvider } from './core/webview-signing'; -import { Message } from './core/message'; -import { initMobileProvider } from './auth/init-mobile-provider'; -import { initWebWalletProvider } from './auth/init-web-wallet-provider'; -import { ls } from './utils/ls-helpers'; -import { - ApiNetworkProvider, - SmartContractQueryArgs, -} from './core/network-provider'; -import { - DappProvider, - LoginMethodsEnum, - LoginOptions, - InitOptions, - EventStoreEvents, -} from './types'; -import { logout } from './auth/logout'; -import { loginWithExtension } from './auth/login-with-extension'; -import { loginWithMobile } from './auth/login-with-mobile'; -import { loginWithWebWallet } from './auth/login-with-web-wallet'; -import { accountSync } from './auth/account-sync'; -import { errorParse } from './utils/error-parse'; -import { isLoginExpired } from './auth/expires-at'; -import { EventsStore } from './events-store'; -import { - networkConfig, - defaultApiEndpoint, - defaultChainTypeConfig, - defaultWalletConnectV2RelayAddresses, -} from './utils/constants'; -import { getParamFromUrl } from './utils/get-param-from-url'; -import { postSendTx } from './interaction/post-send-tx'; -import { webWalletTxFinalize } from './interaction/web-wallet-tx-finalize'; -import { - checkNeedsGuardianSigning, - guardianPreSignTxOperations, - sendTxToGuardian, -} from './interaction/guardian-operations'; -import { preSendTx } from './interaction/pre-send-tx'; -import { webWalletSignMessageFinalize } from './interaction/web-wallet-sign-message-finalize'; -import { loginWithNativeAuthToken } from './auth/login-with-native-auth-token'; -import { initializeEventsStore } from './initialize-events-store'; -import { withLoginEvents } from './utils/with-login-events'; -import { bytesToHex, stringToBytes } from './core/utils'; - -export class ElvenJS { - private static initOptions: InitOptions | undefined; - static dappProvider: DappProvider; - static networkProvider: ApiNetworkProvider | undefined; - - /** - * Initialization of the Elven.js - */ - static async init(options: InitOptions) { - const state = ls.get(); - - if (state.expires && isLoginExpired(state.expires)) { - ls.clear(); - this.dappProvider = undefined; - return; - } - - this.initOptions = { - chainType: defaultChainTypeConfig, - apiUrl: defaultApiEndpoint, - apiTimeout: 10000, - walletConnectV2ProjectId: '', - walletConnectV2RelayAddresses: defaultWalletConnectV2RelayAddresses, - ...options, - }; - - this.networkProvider = new ApiNetworkProvider(this.initOptions); - - initializeEventsStore(this.initOptions); - - // Catch the nativeAuthToken and login with it (for example within xPortal Hub) - const nativeAuthTokenFromUrl = getParamFromUrl('accessToken'); - if (nativeAuthTokenFromUrl) { - await withLoginEvents(async (onLoginSuccess) => { - loginWithNativeAuthToken(nativeAuthTokenFromUrl, this); - await accountSync(this); - onLoginSuccess(); - }); - } - - const isAddress = - state?.address || - ((state.loginMethod === LoginMethodsEnum.webWallet || - state.loginMethod === LoginMethodsEnum.xAlias) && - getParamFromUrl('address')); - - if (isAddress && state?.loginMethod) { - await withLoginEvents(async (onLoginSuccess) => { - if (state.loginMethod === LoginMethodsEnum.browserExtension) { - this.dappProvider = await initExtensionProvider(); - } - if (state.loginMethod === LoginMethodsEnum.mobile) { - this.dappProvider = await initMobileProvider(this); - } - if (state.loginMethod === LoginMethodsEnum.webview) { - this.dappProvider = new WebviewProvider(); - } - if ( - state.loginMethod === LoginMethodsEnum.webWallet && - this.initOptions?.chainType - ) { - this.dappProvider = await initWebWalletProvider( - networkConfig[this.initOptions.chainType].walletAddress, - this.initOptions.apiUrl - ); - } - if ( - state.loginMethod === LoginMethodsEnum.xAlias && - this.initOptions?.chainType - ) { - this.dappProvider = await initWebWalletProvider( - networkConfig[this.initOptions.chainType].xAliasAddress, - this.initOptions.apiUrl - ); - } - await accountSync(this); - onLoginSuccess(); - }); - - // After successful web wallet transaction (or guarded transaction that use web wallet 2FA hook) we will land back on our website - if (this.initOptions?.chainType) { - // We need to get params from callback url and finalize the transaction - // It will only trigger when there is a WALLET_PROVIDER_CALLBACK_PARAM_TX_SIGNED in url params - await webWalletTxFinalize( - this.dappProvider, - this.networkProvider, - networkConfig[this.initOptions.chainType][ - state.loginMethod === LoginMethodsEnum.xAlias - ? 'xAliasAddress' - : 'walletAddress' - ], - state.nonce - ); - - // We need to get the signature in case of signing a message with web wallet or guardians 2FA hook - webWalletSignMessageFinalize(); - } - } - } - - /** - * Login function - */ - static async login(loginMethod: LoginMethodsEnum, options?: LoginOptions) { - const isProperLoginMethod = - Object.values(LoginMethodsEnum).includes(loginMethod); - if (!isProperLoginMethod) { - const error = 'Wrong login method!'; - EventsStore.run(EventStoreEvents.onLoginFailure, error); - throw new Error(error); - } - - if (!this.networkProvider) { - const error = 'Login failed: Use ElvenJs.init() first!'; - EventsStore.run(EventStoreEvents.onLoginFailure, error); - throw new Error(error); - } - - await withLoginEvents(async () => { - // Native auth login token initialization - const nativeAuthClient = new NativeAuthClient({ - apiUrl: this.initOptions?.apiUrl, - origin: window.location.origin, - }); - - const loginToken = await nativeAuthClient.initialize(); - - // Login with browser extension - if (loginMethod === LoginMethodsEnum.browserExtension) { - const dappProvider = await loginWithExtension( - this, - loginToken, - nativeAuthClient, - options?.callbackRoute - ); - this.dappProvider = dappProvider; - } - - // Login with mobile app - if (loginMethod === LoginMethodsEnum.mobile) { - const dappProvider = await loginWithMobile( - this, - loginToken, - nativeAuthClient, - options?.qrCodeContainer - ); - this.dappProvider = dappProvider; - } - - // Login with Web Wallet - if ( - loginMethod === LoginMethodsEnum.webWallet && - this.initOptions?.chainType - ) { - const dappProvider = await loginWithWebWallet( - networkConfig[this.initOptions.chainType].walletAddress, - loginToken, - this.initOptions?.chainType, - options?.callbackRoute - ); - this.dappProvider = dappProvider; - } - - // Login with xAlias - if ( - loginMethod === LoginMethodsEnum.xAlias && - this.initOptions?.chainType - ) { - // Login with xAlias is almost the same as with the web wallet, only endpoints are different - const dappProvider = await loginWithWebWallet( - networkConfig[this.initOptions.chainType].xAliasAddress, - loginToken, - this.initOptions?.chainType, - options?.callbackRoute - ); - this.dappProvider = dappProvider; - } - }); - } - - /** - * Logout function - */ - static async logout() { - try { - const isLoggedOut = await logout(this); - this.dappProvider = undefined; - return isLoggedOut; - } catch (e) { - const err = errorParse(e); - console.warn('Something went wrong when logging out: ', err); - } - } - - /** - * Sign and send function - */ - static async signAndSendTransaction(transaction: Transaction) { - if (!this.dappProvider) { - const error = 'Transaction signing failed: There is no active session!'; - EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); - throw new Error(error); - } - if (!this.networkProvider) { - const error = - 'Transaction signing failed: There is no active network provider!'; - EventsStore.run(EventStoreEvents.onTxFailure, transaction, error); - throw new Error(error); - } - - let signedTx = guardianPreSignTxOperations(transaction); - - try { - EventsStore.run(EventStoreEvents.onTxStart, transaction); - - const currentState = ls.get(); - - transaction.nonce = currentState.nonce; - - if (this.dappProvider instanceof ExtensionProvider) { - signedTx = await this.dappProvider.signTransaction(transaction); - } - if (this.dappProvider instanceof WalletConnectV2Provider) { - signedTx = await this.dappProvider.signTransaction(transaction); - } - if (this.dappProvider instanceof WebviewProvider) { - signedTx = await this.dappProvider.signTransaction(transaction); - } - if (this.dappProvider instanceof WalletProvider) { - await this.dappProvider.signTransaction(transaction); - } - - if ( - currentState.loginMethod !== LoginMethodsEnum.webWallet && - currentState.loginMethod !== LoginMethodsEnum.xAlias - ) { - const needsGuardianSign = checkNeedsGuardianSigning(signedTx); - - if (!needsGuardianSign) { - preSendTx(signedTx); - } - - if (needsGuardianSign && this.initOptions?.chainType) { - await sendTxToGuardian( - signedTx, - networkConfig[this.initOptions.chainType].walletAddress - ); - - return; - } - - const response = await this.networkProvider.sendTransaction(signedTx); - await postSendTx(response, this.networkProvider); - } - } catch (e) { - const err = errorParse(e); - EventsStore.run( - EventStoreEvents.onTxFailure, - signedTx, - `Getting transaction information failed! ${err}` - ); - throw new Error(`Getting transaction information failed! ${err}`); - } - - return signedTx; - } - - /** - * Sign a single message - */ - static async signMessage( - message: string, - options?: { callbackUrl?: string } - ) { - if (!this.dappProvider) { - const error = 'Message signing failed: There is no active session!'; - EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); - throw new Error(error); - } - if (!this.networkProvider) { - const error = - 'Message signing failed: There is no active network provider!'; - EventsStore.run(EventStoreEvents.onSignMsgFailure, message, error); - throw new Error(error); - } - - let messageSignature = ''; - - try { - EventsStore.run(EventStoreEvents.onSignMsgStart, message); - - if (this.dappProvider instanceof ExtensionProvider) { - const signedMessage = await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }) - ); - - if (signedMessage?.signature) { - messageSignature = bytesToHex(signedMessage.signature); - } - } - if (this.dappProvider instanceof WalletConnectV2Provider) { - const signedMessage = await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }) - ); - - if (signedMessage?.signature) { - messageSignature = bytesToHex(signedMessage.signature); - } - } - - if (this.dappProvider instanceof WebviewProvider) { - const signedMessage = await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }) - ); - - if (signedMessage?.signature) { - messageSignature = bytesToHex(signedMessage.signature); - } - } - if (this.dappProvider instanceof WalletProvider) { - const encodeRFC3986URIComponent = (str: string) => { - return encodeURIComponent(str).replace( - /[!'()*]/g, - (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}` - ); - }; - - const url = options?.callbackUrl || window.location.origin; - await this.dappProvider.signMessage( - new Message({ data: stringToBytes(message) }), - { - callbackUrl: encodeURIComponent( - `${url}${ - url.includes('?') ? '&' : '?' - }message=${encodeRFC3986URIComponent(message)}` - ), - } - ); - } - - const currentState = ls.get(); - - if ( - currentState.loginMethod !== LoginMethodsEnum.webWallet && - currentState.loginMethod !== LoginMethodsEnum.xAlias - ) { - EventsStore.run( - EventStoreEvents.onSignMsgFinalized, - message, - messageSignature - ); - } - - return { message, messageSignature }; - } catch (e) { - const err = errorParse(e); - EventsStore.run(EventStoreEvents.onSignMsgFailure, message, err); - throw new Error(`Message signing failed! ${err}`); - } - } - - /** - * Query Smart Contracts - */ - static async queryContract({ - address, - func, - args = [], - value = 0, - caller, - }: SmartContractQueryArgs) { - if (!this.networkProvider) { - throw new Error('Query failed: There is no active network provider!'); - } - - if (!address || !func) { - throw new Error( - 'Query failed: The Query arguments are not valid! Address and func required' - ); - } - - const queryArgs = { - address, - func, - args, - value, - caller, - }; - - try { - EventsStore.run(EventStoreEvents.onQueryStart, queryArgs); - const response = await this.networkProvider.queryContract(queryArgs); - EventsStore.run(EventStoreEvents.onQueryFinalized, response); - return response; - } catch (e) { - const err = errorParse(e); - EventsStore.run(EventStoreEvents.onQueryFinalized, queryArgs, err); - throw new Error(`Smart contract query failed! ${err}`); - } - } - - /** - * Main storage - */ - static storage = ls; - - /** - * Destroy and cleanup if needed - */ - static destroy = () => { - this.networkProvider = undefined; - this.dappProvider = undefined; - this.initOptions = undefined; - EventsStore.clear(); - }; -} diff --git a/tsconfig.json b/tsconfig.json index 22e8b9c..f3c8410 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,14 @@ { - "include": ["src/**/*"], + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./configs/tsconfig/base.json", "compilerOptions": { - "strict": true, - "target": "ES2020", - "module": "ES2020", - "declaration": true, - "declarationDir": "build/types", - "emitDeclarationOnly": true, - "moduleResolution": "Node", - "allowSyntheticDefaultImports": true, - "resolveJsonModule": true, - "types": ["node"], - "skipLibCheck": true, + "baseUrl": ".", + "paths": { + "elven.js(/*)": ["packages/elven.js/src$1"], + "mobile-signing-provider(/*)": ["packages/mobile-signing-provider/src$1"] + }, + "types": ["node"] }, + "include": ["packages/*/src/**/*"], + "exclude": ["node_modules"] } diff --git a/turbo.json b/turbo.json new file mode 100644 index 0000000..5de72fa --- /dev/null +++ b/turbo.json @@ -0,0 +1,32 @@ +{ + "$schema": "https://turbo.build/schema.json", + "globalDependencies": [ + ".env" + ], + "tasks": { + "build": { + "cache": false, + "dependsOn": [ + "^build" + ], + "outputs": [ + "build/**" + ] + }, + "lint": { + "outputs": [], + "cache": true + }, + "check-types": { + "cache": true, + "outputs": [] + }, + "prettier": { + "cache": true, + "outputs": [] + }, + "clean": { + "cache": false + } + } +} \ No newline at end of file