@0xfutbol/id
Version:
React component library with shared providers for 0xFutbol ID
696 lines (611 loc) • 78 kB
JavaScript
import {bX as commonjsGlobal,S as getDefaultExportFromCjs,bY as eventsExports,bZ as isHttpUrl,b_ as safeJsonStringify,b$ as safeJsonParse,c0 as formatJsonRpcError,c1 as parseConnectionError,c2 as Ct,c3 as $t,c4 as k$1,c5 as formatJsonRpcResult,c6 as de$1,c7 as $e$1,c8 as Ee$1,c9 as pr,ca as Tt$1,cb as Ye$1,cc as o$3,cd as formatJsonRpcRequest,ce as qe$1,cf as Q$1,cg as Kr}from'./index-BJCJzM2_.js';import'react';import'react/jsx-runtime';import'@0xfutbol/id-sign';import'react-use';import'@0xfutbol/constants';import'thirdweb';import'@matchain/matchid-sdk-react';import'@tanstack/react-query';import'@matchain/matchid-sdk-react/index.css';import'react-dom';var browserPonyfill = {exports: {}};var hasRequiredBrowserPonyfill;
function requireBrowserPonyfill () {
if (hasRequiredBrowserPonyfill) return browserPonyfill.exports;
hasRequiredBrowserPonyfill = 1;
(function (module, exports) {
// Save global object in a variable
var __global__ =
(typeof globalThis !== 'undefined' && globalThis) ||
(typeof self !== 'undefined' && self) ||
(typeof commonjsGlobal !== 'undefined' && commonjsGlobal);
// Create an object that extends from __global__ without the fetch function
var __globalThis__ = (function () {
function F() {
this.fetch = false;
this.DOMException = __global__.DOMException;
}
F.prototype = __global__; // Needed for feature detection on whatwg-fetch's code
return new F();
})();
// Wraps whatwg-fetch with a function scope to hijack the global object
// "globalThis" that's going to be patched
(function(globalThis) {
((function (exports) {
/* eslint-disable no-prototype-builtins */
var g =
(typeof globalThis !== 'undefined' && globalThis) ||
(typeof self !== 'undefined' && self) ||
// eslint-disable-next-line no-undef
(typeof commonjsGlobal !== 'undefined' && commonjsGlobal) ||
{};
var support = {
searchParams: 'URLSearchParams' in g,
iterable: 'Symbol' in g && 'iterator' in Symbol,
blob:
'FileReader' in g &&
'Blob' in g &&
(function() {
try {
new Blob();
return true
} catch (e) {
return false
}
})(),
formData: 'FormData' in g,
arrayBuffer: 'ArrayBuffer' in g
};
function isDataView(obj) {
return obj && DataView.prototype.isPrototypeOf(obj)
}
if (support.arrayBuffer) {
var viewClasses = [
'[object Int8Array]',
'[object Uint8Array]',
'[object Uint8ClampedArray]',
'[object Int16Array]',
'[object Uint16Array]',
'[object Int32Array]',
'[object Uint32Array]',
'[object Float32Array]',
'[object Float64Array]'
];
var isArrayBufferView =
ArrayBuffer.isView ||
function(obj) {
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1
};
}
function normalizeName(name) {
if (typeof name !== 'string') {
name = String(name);
}
if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === '') {
throw new TypeError('Invalid character in header field name: "' + name + '"')
}
return name.toLowerCase()
}
function normalizeValue(value) {
if (typeof value !== 'string') {
value = String(value);
}
return value
}
// Build a destructive iterator for the value list
function iteratorFor(items) {
var iterator = {
next: function() {
var value = items.shift();
return {done: value === undefined, value: value}
}
};
if (support.iterable) {
iterator[Symbol.iterator] = function() {
return iterator
};
}
return iterator
}
function Headers(headers) {
this.map = {};
if (headers instanceof Headers) {
headers.forEach(function(value, name) {
this.append(name, value);
}, this);
} else if (Array.isArray(headers)) {
headers.forEach(function(header) {
if (header.length != 2) {
throw new TypeError('Headers constructor: expected name/value pair to be length 2, found' + header.length)
}
this.append(header[0], header[1]);
}, this);
} else if (headers) {
Object.getOwnPropertyNames(headers).forEach(function(name) {
this.append(name, headers[name]);
}, this);
}
}
Headers.prototype.append = function(name, value) {
name = normalizeName(name);
value = normalizeValue(value);
var oldValue = this.map[name];
this.map[name] = oldValue ? oldValue + ', ' + value : value;
};
Headers.prototype['delete'] = function(name) {
delete this.map[normalizeName(name)];
};
Headers.prototype.get = function(name) {
name = normalizeName(name);
return this.has(name) ? this.map[name] : null
};
Headers.prototype.has = function(name) {
return this.map.hasOwnProperty(normalizeName(name))
};
Headers.prototype.set = function(name, value) {
this.map[normalizeName(name)] = normalizeValue(value);
};
Headers.prototype.forEach = function(callback, thisArg) {
for (var name in this.map) {
if (this.map.hasOwnProperty(name)) {
callback.call(thisArg, this.map[name], name, this);
}
}
};
Headers.prototype.keys = function() {
var items = [];
this.forEach(function(value, name) {
items.push(name);
});
return iteratorFor(items)
};
Headers.prototype.values = function() {
var items = [];
this.forEach(function(value) {
items.push(value);
});
return iteratorFor(items)
};
Headers.prototype.entries = function() {
var items = [];
this.forEach(function(value, name) {
items.push([name, value]);
});
return iteratorFor(items)
};
if (support.iterable) {
Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
}
function consumed(body) {
if (body._noBody) return
if (body.bodyUsed) {
return Promise.reject(new TypeError('Already read'))
}
body.bodyUsed = true;
}
function fileReaderReady(reader) {
return new Promise(function(resolve, reject) {
reader.onload = function() {
resolve(reader.result);
};
reader.onerror = function() {
reject(reader.error);
};
})
}
function readBlobAsArrayBuffer(blob) {
var reader = new FileReader();
var promise = fileReaderReady(reader);
reader.readAsArrayBuffer(blob);
return promise
}
function readBlobAsText(blob) {
var reader = new FileReader();
var promise = fileReaderReady(reader);
var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
var encoding = match ? match[1] : 'utf-8';
reader.readAsText(blob, encoding);
return promise
}
function readArrayBufferAsText(buf) {
var view = new Uint8Array(buf);
var chars = new Array(view.length);
for (var i = 0; i < view.length; i++) {
chars[i] = String.fromCharCode(view[i]);
}
return chars.join('')
}
function bufferClone(buf) {
if (buf.slice) {
return buf.slice(0)
} else {
var view = new Uint8Array(buf.byteLength);
view.set(new Uint8Array(buf));
return view.buffer
}
}
function Body() {
this.bodyUsed = false;
this._initBody = function(body) {
/*
fetch-mock wraps the Response object in an ES6 Proxy to
provide useful test harness features such as flush. However, on
ES5 browsers without fetch or Proxy support pollyfills must be used;
the proxy-pollyfill is unable to proxy an attribute unless it exists
on the object before the Proxy is created. This change ensures
Response.bodyUsed exists on the instance, while maintaining the
semantic of setting Request.bodyUsed in the constructor before
_initBody is called.
*/
// eslint-disable-next-line no-self-assign
this.bodyUsed = this.bodyUsed;
this._bodyInit = body;
if (!body) {
this._noBody = true;
this._bodyText = '';
} else if (typeof body === 'string') {
this._bodyText = body;
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
this._bodyBlob = body;
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
this._bodyFormData = body;
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this._bodyText = body.toString();
} else if (support.arrayBuffer && support.blob && isDataView(body)) {
this._bodyArrayBuffer = bufferClone(body.buffer);
// IE 10-11 can't handle a DataView body.
this._bodyInit = new Blob([this._bodyArrayBuffer]);
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
this._bodyArrayBuffer = bufferClone(body);
} else {
this._bodyText = body = Object.prototype.toString.call(body);
}
if (!this.headers.get('content-type')) {
if (typeof body === 'string') {
this.headers.set('content-type', 'text/plain;charset=UTF-8');
} else if (this._bodyBlob && this._bodyBlob.type) {
this.headers.set('content-type', this._bodyBlob.type);
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');
}
}
};
if (support.blob) {
this.blob = function() {
var rejected = consumed(this);
if (rejected) {
return rejected
}
if (this._bodyBlob) {
return Promise.resolve(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(new Blob([this._bodyArrayBuffer]))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as blob')
} else {
return Promise.resolve(new Blob([this._bodyText]))
}
};
}
this.arrayBuffer = function() {
if (this._bodyArrayBuffer) {
var isConsumed = consumed(this);
if (isConsumed) {
return isConsumed
} else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
return Promise.resolve(
this._bodyArrayBuffer.buffer.slice(
this._bodyArrayBuffer.byteOffset,
this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
)
)
} else {
return Promise.resolve(this._bodyArrayBuffer)
}
} else if (support.blob) {
return this.blob().then(readBlobAsArrayBuffer)
} else {
throw new Error('could not read as ArrayBuffer')
}
};
this.text = function() {
var rejected = consumed(this);
if (rejected) {
return rejected
}
if (this._bodyBlob) {
return readBlobAsText(this._bodyBlob)
} else if (this._bodyArrayBuffer) {
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))
} else if (this._bodyFormData) {
throw new Error('could not read FormData body as text')
} else {
return Promise.resolve(this._bodyText)
}
};
if (support.formData) {
this.formData = function() {
return this.text().then(decode)
};
}
this.json = function() {
return this.text().then(JSON.parse)
};
return this
}
// HTTP methods whose capitalization should be normalized
var methods = ['CONNECT', 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'PATCH', 'POST', 'PUT', 'TRACE'];
function normalizeMethod(method) {
var upcased = method.toUpperCase();
return methods.indexOf(upcased) > -1 ? upcased : method
}
function Request(input, options) {
if (!(this instanceof Request)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
}
options = options || {};
var body = options.body;
if (input instanceof Request) {
if (input.bodyUsed) {
throw new TypeError('Already read')
}
this.url = input.url;
this.credentials = input.credentials;
if (!options.headers) {
this.headers = new Headers(input.headers);
}
this.method = input.method;
this.mode = input.mode;
this.signal = input.signal;
if (!body && input._bodyInit != null) {
body = input._bodyInit;
input.bodyUsed = true;
}
} else {
this.url = String(input);
}
this.credentials = options.credentials || this.credentials || 'same-origin';
if (options.headers || !this.headers) {
this.headers = new Headers(options.headers);
}
this.method = normalizeMethod(options.method || this.method || 'GET');
this.mode = options.mode || this.mode || null;
this.signal = options.signal || this.signal || (function () {
if ('AbortController' in g) {
var ctrl = new AbortController();
return ctrl.signal;
}
}());
this.referrer = null;
if ((this.method === 'GET' || this.method === 'HEAD') && body) {
throw new TypeError('Body not allowed for GET or HEAD requests')
}
this._initBody(body);
if (this.method === 'GET' || this.method === 'HEAD') {
if (options.cache === 'no-store' || options.cache === 'no-cache') {
// Search for a '_' parameter in the query string
var reParamSearch = /([?&])_=[^&]*/;
if (reParamSearch.test(this.url)) {
// If it already exists then set the value with the current time
this.url = this.url.replace(reParamSearch, '$1_=' + new Date().getTime());
} else {
// Otherwise add a new '_' parameter to the end with the current time
var reQueryString = /\?/;
this.url += (reQueryString.test(this.url) ? '&' : '?') + '_=' + new Date().getTime();
}
}
}
}
Request.prototype.clone = function() {
return new Request(this, {body: this._bodyInit})
};
function decode(body) {
var form = new FormData();
body
.trim()
.split('&')
.forEach(function(bytes) {
if (bytes) {
var split = bytes.split('=');
var name = split.shift().replace(/\+/g, ' ');
var value = split.join('=').replace(/\+/g, ' ');
form.append(decodeURIComponent(name), decodeURIComponent(value));
}
});
return form
}
function parseHeaders(rawHeaders) {
var headers = new Headers();
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
// https://tools.ietf.org/html/rfc7230#section-3.2
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' ');
// Avoiding split via regex to work around a common IE11 bug with the core-js 3.6.0 regex polyfill
// https://github.com/github/fetch/issues/748
// https://github.com/zloirock/core-js/issues/751
preProcessedHeaders
.split('\r')
.map(function(header) {
return header.indexOf('\n') === 0 ? header.substr(1, header.length) : header
})
.forEach(function(line) {
var parts = line.split(':');
var key = parts.shift().trim();
if (key) {
var value = parts.join(':').trim();
try {
headers.append(key, value);
} catch (error) {
console.warn('Response ' + error.message);
}
}
});
return headers
}
Body.call(Request.prototype);
function Response(bodyInit, options) {
if (!(this instanceof Response)) {
throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.')
}
if (!options) {
options = {};
}
this.type = 'default';
this.status = options.status === undefined ? 200 : options.status;
if (this.status < 200 || this.status > 599) {
throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].")
}
this.ok = this.status >= 200 && this.status < 300;
this.statusText = options.statusText === undefined ? '' : '' + options.statusText;
this.headers = new Headers(options.headers);
this.url = options.url || '';
this._initBody(bodyInit);
}
Body.call(Response.prototype);
Response.prototype.clone = function() {
return new Response(this._bodyInit, {
status: this.status,
statusText: this.statusText,
headers: new Headers(this.headers),
url: this.url
})
};
Response.error = function() {
var response = new Response(null, {status: 200, statusText: ''});
response.ok = false;
response.status = 0;
response.type = 'error';
return response
};
var redirectStatuses = [301, 302, 303, 307, 308];
Response.redirect = function(url, status) {
if (redirectStatuses.indexOf(status) === -1) {
throw new RangeError('Invalid status code')
}
return new Response(null, {status: status, headers: {location: url}})
};
exports.DOMException = g.DOMException;
try {
new exports.DOMException();
} catch (err) {
exports.DOMException = function(message, name) {
this.message = message;
this.name = name;
var error = Error(message);
this.stack = error.stack;
};
exports.DOMException.prototype = Object.create(Error.prototype);
exports.DOMException.prototype.constructor = exports.DOMException;
}
function fetch(input, init) {
return new Promise(function(resolve, reject) {
var request = new Request(input, init);
if (request.signal && request.signal.aborted) {
return reject(new exports.DOMException('Aborted', 'AbortError'))
}
var xhr = new XMLHttpRequest();
function abortXhr() {
xhr.abort();
}
xhr.onload = function() {
var options = {
statusText: xhr.statusText,
headers: parseHeaders(xhr.getAllResponseHeaders() || '')
};
// This check if specifically for when a user fetches a file locally from the file system
// Only if the status is out of a normal range
if (request.url.indexOf('file://') === 0 && (xhr.status < 200 || xhr.status > 599)) {
options.status = 200;
} else {
options.status = xhr.status;
}
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');
var body = 'response' in xhr ? xhr.response : xhr.responseText;
setTimeout(function() {
resolve(new Response(body, options));
}, 0);
};
xhr.onerror = function() {
setTimeout(function() {
reject(new TypeError('Network request failed'));
}, 0);
};
xhr.ontimeout = function() {
setTimeout(function() {
reject(new TypeError('Network request timed out'));
}, 0);
};
xhr.onabort = function() {
setTimeout(function() {
reject(new exports.DOMException('Aborted', 'AbortError'));
}, 0);
};
function fixUrl(url) {
try {
return url === '' && g.location.href ? g.location.href : url
} catch (e) {
return url
}
}
xhr.open(request.method, fixUrl(request.url), true);
if (request.credentials === 'include') {
xhr.withCredentials = true;
} else if (request.credentials === 'omit') {
xhr.withCredentials = false;
}
if ('responseType' in xhr) {
if (support.blob) {
xhr.responseType = 'blob';
} else if (
support.arrayBuffer
) {
xhr.responseType = 'arraybuffer';
}
}
if (init && typeof init.headers === 'object' && !(init.headers instanceof Headers || (g.Headers && init.headers instanceof g.Headers))) {
var names = [];
Object.getOwnPropertyNames(init.headers).forEach(function(name) {
names.push(normalizeName(name));
xhr.setRequestHeader(name, normalizeValue(init.headers[name]));
});
request.headers.forEach(function(value, name) {
if (names.indexOf(name) === -1) {
xhr.setRequestHeader(name, value);
}
});
} else {
request.headers.forEach(function(value, name) {
xhr.setRequestHeader(name, value);
});
}
if (request.signal) {
request.signal.addEventListener('abort', abortXhr);
xhr.onreadystatechange = function() {
// DONE (success or failure)
if (xhr.readyState === 4) {
request.signal.removeEventListener('abort', abortXhr);
}
};
}
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);
})
}
fetch.polyfill = true;
if (!g.fetch) {
g.fetch = fetch;
g.Headers = Headers;
g.Request = Request;
g.Response = Response;
}
exports.Headers = Headers;
exports.Request = Request;
exports.Response = Response;
exports.fetch = fetch;
Object.defineProperty(exports, '__esModule', { value: true });
return exports;
}))({});
})(__globalThis__);
// This is a ponyfill, so...
__globalThis__.fetch.ponyfill = true;
delete __globalThis__.fetch.polyfill;
// Choose between native implementation (__global__) or custom implementation (__globalThis__)
var ctx = __global__.fetch ? __global__ : __globalThis__;
exports = ctx.fetch; // To enable: import fetch from 'cross-fetch'
exports.default = ctx.fetch; // For TypeScript consumers without esModuleInterop.
exports.fetch = ctx.fetch; // To enable: import {fetch} from 'cross-fetch'
exports.Headers = ctx.Headers;
exports.Request = ctx.Request;
exports.Response = ctx.Response;
module.exports = exports;
} (browserPonyfill, browserPonyfill.exports));
return browserPonyfill.exports;
}var browserPonyfillExports = requireBrowserPonyfill();
var o$2 = /*@__PURE__*/getDefaultExportFromCjs(browserPonyfillExports);var P$2=Object.defineProperty,w$2=Object.defineProperties,E$1=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,L$2=Object.prototype.hasOwnProperty,O$2=Object.prototype.propertyIsEnumerable,l=(r,t,e)=>t in r?P$2(r,t,{enumerable:true,configurable:true,writable:true,value:e}):r[t]=e,p$1=(r,t)=>{for(var e in t||(t={}))L$2.call(t,e)&&l(r,e,t[e]);if(c)for(var e of c(t))O$2.call(t,e)&&l(r,e,t[e]);return r},v$1=(r,t)=>w$2(r,E$1(t));const j$1={Accept:"application/json","Content-Type":"application/json"},T$1="POST",d$1={headers:j$1,method:T$1},g$2=10;class f{constructor(t,e=false){if(this.url=t,this.disableProviderPing=e,this.events=new eventsExports.EventEmitter,this.isAvailable=false,this.registering=false,!isHttpUrl(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);this.url=t,this.disableProviderPing=e;}get connected(){return this.isAvailable}get connecting(){return this.registering}on(t,e){this.events.on(t,e);}once(t,e){this.events.once(t,e);}off(t,e){this.events.off(t,e);}removeListener(t,e){this.events.removeListener(t,e);}async open(t=this.url){await this.register(t);}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose();}async send(t){this.isAvailable||await this.register();try{const e=safeJsonStringify(t),s=await(await o$2(this.url,v$1(p$1({},d$1),{body:e}))).json();this.onPayload({data:s});}catch(e){this.onError(t.id,e);}}async register(t=this.url){if(!isHttpUrl(t))throw new Error(`Provided URL is not compatible with HTTP connection: ${t}`);if(this.registering){const e=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((s,i)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),i(n);}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));s();});})}this.url=t,this.registering=true;try{if(!this.disableProviderPing){const e=safeJsonStringify({id:1,jsonrpc:"2.0",method:"test",params:[]});await o$2(t,v$1(p$1({},d$1),{body:e}));}this.onOpen();}catch(e){const s=this.parseError(e);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=true,this.registering=false,this.events.emit("open");}onClose(){this.isAvailable=false,this.registering=false,this.events.emit("close");}onPayload(t){if(typeof t.data>"u")return;const e=typeof t.data=="string"?safeJsonParse(t.data):t.data;this.events.emit("payload",e);}onError(t,e){const s=this.parseError(e),i=s.message||s.toString(),n=formatJsonRpcError(t,i);this.events.emit("payload",n);}parseError(t,e=this.url){return parseConnectionError(t,e,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>g$2&&this.events.setMaxListeners(g$2);}}const tt="error",Nt="wss://relay.walletconnect.org",St="wc",Dt="universal_provider",_$1=`${St}@2:${Dt}:`,et="https://rpc.walletconnect.org/v1/",w$1="generic",qt=`${et}bundler`,d={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function jt(){}function B(s){return s==null||typeof s!="object"&&typeof s!="function"}function G(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Rt(s){if(B(s))return s;if(Array.isArray(s)||G(s)||s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer)return s.slice(0);const t=Object.getPrototypeOf(s),e=t.constructor;if(s instanceof Date||s instanceof Map||s instanceof Set)return new e(s);if(s instanceof RegExp){const i=new e(s);return i.lastIndex=s.lastIndex,i}if(s instanceof DataView)return new e(s.buffer.slice(0));if(s instanceof Error){const i=new e(s.message);return i.stack=s.stack,i.name=s.name,i.cause=s.cause,i}if(typeof File<"u"&&s instanceof File)return new e([s],s.name,{type:s.type,lastModified:s.lastModified});if(typeof s=="object"){const i=Object.create(t);return Object.assign(i,s)}return s}function st(s){return typeof s=="object"&&s!==null}function it(s){return Object.getOwnPropertySymbols(s).filter(t=>Object.prototype.propertyIsEnumerable.call(s,t))}function rt(s){return s==null?s===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(s)}const _t="[object RegExp]",nt="[object String]",at="[object Number]",ct="[object Boolean]",ot="[object Arguments]",Ut="[object Symbol]",Ft="[object Date]",Lt="[object Map]",xt="[object Set]",Mt="[object Array]",Bt="[object ArrayBuffer]",Gt="[object Object]",Jt="[object DataView]",zt="[object Uint8Array]",kt="[object Uint8ClampedArray]",Wt="[object Uint16Array]",Kt="[object Uint32Array]",Vt="[object Int8Array]",Xt="[object Int16Array]",Yt="[object Int32Array]",Qt="[object Float32Array]",Zt="[object Float64Array]";function Tt(s,t){return y$1(s,void 0,s,new Map,t)}function y$1(s,t,e,i=new Map,r=void 0){const a=r?.(s,t,e,i);if(a!=null)return a;if(B(s))return s;if(i.has(s))return i.get(s);if(Array.isArray(s)){const n=new Array(s.length);i.set(s,n);for(let c=0;c<s.length;c++)n[c]=y$1(s[c],c,e,i,r);return Object.hasOwn(s,"index")&&(n.index=s.index),Object.hasOwn(s,"input")&&(n.input=s.input),n}if(s instanceof Date)return new Date(s.getTime());if(s instanceof RegExp){const n=new RegExp(s.source,s.flags);return n.lastIndex=s.lastIndex,n}if(s instanceof Map){const n=new Map;i.set(s,n);for(const[c,h]of s)n.set(c,y$1(h,c,e,i,r));return n}if(s instanceof Set){const n=new Set;i.set(s,n);for(const c of s)n.add(y$1(c,void 0,e,i,r));return n}if(typeof Buffer<"u"&&Buffer.isBuffer(s))return s.subarray();if(G(s)){const n=new(Object.getPrototypeOf(s)).constructor(s.length);i.set(s,n);for(let c=0;c<s.length;c++)n[c]=y$1(s[c],c,e,i,r);return n}if(s instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&s instanceof SharedArrayBuffer)return s.slice(0);if(s instanceof DataView){const n=new DataView(s.buffer.slice(0),s.byteOffset,s.byteLength);return i.set(s,n),g$1(n,s,e,i,r),n}if(typeof File<"u"&&s instanceof File){const n=new File([s],s.name,{type:s.type});return i.set(s,n),g$1(n,s,e,i,r),n}if(s instanceof Blob){const n=new Blob([s],{type:s.type});return i.set(s,n),g$1(n,s,e,i,r),n}if(s instanceof Error){const n=new s.constructor;return i.set(s,n),n.message=s.message,n.name=s.name,n.stack=s.stack,n.cause=s.cause,g$1(n,s,e,i,r),n}if(typeof s=="object"&&te(s)){const n=Object.create(Object.getPrototypeOf(s));return i.set(s,n),g$1(n,s,e,i,r),n}return s}function g$1(s,t,e=s,i,r){const a=[...Object.keys(t),...it(t)];for(let n=0;n<a.length;n++){const c=a[n],h=Object.getOwnPropertyDescriptor(s,c);(h==null||h.writable)&&(s[c]=y$1(t[c],c,e,i,r));}}function te(s){switch(rt(s)){case ot:case Mt:case Bt:case Jt:case ct:case Ft:case Qt:case Zt:case Vt:case Xt:case Yt:case Lt:case at:case Gt:case _t:case xt:case nt:case Ut:case zt:case kt:case Wt:case Kt:return true;default:return false}}function ee(s,t){return Tt(s,(e,i,r,a)=>{if(typeof s=="object")switch(Object.prototype.toString.call(s)){case at:case nt:case ct:{const c=new s.constructor(s?.valueOf());return g$1(c,s),c}case ot:{const c={};return g$1(c,s),c.length=s.length,c[Symbol.iterator]=s[Symbol.iterator],c}default:return}})}function ht(s){return ee(s)}function pt(s){return s!==null&&typeof s=="object"&&rt(s)==="[object Arguments]"}function se(s){return G(s)}function ie(s){if(typeof s!="object"||s==null)return false;if(Object.getPrototypeOf(s)===null)return true;if(Object.prototype.toString.call(s)!=="[object Object]"){const e=s[Symbol.toStringTag];return e==null||!Object.getOwnPropertyDescriptor(s,Symbol.toStringTag)?.writable?false:s.toString()===`[object ${e}]`}let t=s;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(s)===t}function re(s,...t){const e=t.slice(0,-1),i=t[t.length-1];let r=s;for(let a=0;a<e.length;a++){const n=e[a];r=U$1(r,n,i,new Map);}return r}function U$1(s,t,e,i){if(B(s)&&(s=Object(s)),t==null||typeof t!="object")return s;if(i.has(t))return Rt(i.get(t));if(i.set(t,s),Array.isArray(t)){t=t.slice();for(let a=0;a<t.length;a++)t[a]=t[a]??void 0;}const r=[...Object.keys(t),...it(t)];for(let a=0;a<r.length;a++){const n=r[a];let c=t[n],h=s[n];if(pt(c)&&(c={...c}),pt(h)&&(h={...h}),typeof Buffer<"u"&&Buffer.isBuffer(c)&&(c=ht(c)),Array.isArray(c))if(typeof h=="object"&&h!=null){const j=[],R=Reflect.ownKeys(h);for(let f=0;f<R.length;f++){const X=R[f];j[X]=h[X];}h=j;}else h=[];const v=e(h,c,n,s,t,i);v!=null?s[n]=v:Array.isArray(c)||st(h)&&st(c)?s[n]=U$1(h,c,e,i):h==null&&ie(c)?s[n]=U$1({},c,e,i):h==null&&se(c)?s[n]=ht(c):(h===void 0||c!==void 0)&&(s[n]=c);}return s}function ne(s,...t){return re(s,...t,jt)}var ae=Object.defineProperty,ce=Object.defineProperties,oe=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable,ut=(s,t,e)=>t in s?ae(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,F=(s,t)=>{for(var e in t||(t={}))he.call(t,e)&&ut(s,e,t[e]);if(dt)for(var e of dt(t))pe.call(t,e)&&ut(s,e,t[e]);return s},de=(s,t)=>ce(s,oe(t));function p(s,t,e){var i;const r=Ye$1(s);return ((i=t.rpcMap)==null?void 0:i[r.reference])||`${et}?chainId=${r.namespace}:${r.reference}&projectId=${e}`}function P$1(s){return s.includes(":")?s.split(":")[1]:s}function lt(s){return s.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function ue(s,t){const e=Object.keys(t.namespaces).filter(r=>r.includes(s));if(!e.length)return [];const i=[];return e.forEach(r=>{const a=t.namespaces[r].accounts;i.push(...a);}),i}function J(s={},t={}){const e=ft(s),i=ft(t);return ne(e,i)}function ft(s){var t,e,i,r;const a={};if(!qe$1(s))return a;for(const[n,c]of Object.entries(s)){const h=Tt$1(n)?[n]:c.chains,v=c.methods||[],j=c.events||[],R=c.rpcMap||{},f=pr(n);a[f]=de(F(F({},a[f]),c),{chains:Q$1(h,(t=a[f])==null?void 0:t.chains),methods:Q$1(v,(e=a[f])==null?void 0:e.methods),events:Q$1(j,(i=a[f])==null?void 0:i.events),rpcMap:F(F({},R),(r=a[f])==null?void 0:r.rpcMap)});}return a}function le(s){return s.includes(":")?s.split(":")[2]:s}function mt(s){const t={};for(const[e,i]of Object.entries(s)){const r=i.methods||[],a=i.events||[],n=i.accounts||[],c=Tt$1(e)?[e]:i.chains?i.chains:lt(i.accounts);t[e]={chains:c,methods:r,events:a,accounts:n};}return t}function z$1(s){return typeof s=="number"?s:s.includes("0x")?parseInt(s,16):(s=s.includes(":")?s.split(":")[1]:s,isNaN(Number(s))?s:Number(s))}const vt={},o$1=s=>vt[s],k=(s,t)=>{vt[s]=t;};var fe=Object.defineProperty,me=(s,t,e)=>t in s?fe(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,b=(s,t,e)=>me(s,typeof t!="symbol"?t+"":t,e);class ve{constructor(t){b(this,"name","polkadot"),b(this,"client"),b(this,"httpProviders"),b(this,"events"),b(this,"namespace"),b(this,"chainId"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`);}getAccounts(){const t=this.namespace.accounts;return t?t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const r=P$1(e);t[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[e]);}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProvider(t,e){const i=e||p(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new o$3(new f(i,o$1("disableProviderPing")))}}var ge=Object.defineProperty,Pe=Object.defineProperties,we=Object.getOwnPropertyDescriptors,gt=Object.getOwnPropertySymbols,ye=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable,W=(s,t,e)=>t in s?ge(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,Pt=(s,t)=>{for(var e in t||(t={}))ye.call(t,e)&&W(s,e,t[e]);if(gt)for(var e of gt(t))be.call(t,e)&&W(s,e,t[e]);return s},wt=(s,t)=>Pe(s,we(t)),I=(s,t,e)=>W(s,typeof t!="symbol"?t+"":t,e);class Ie{constructor(t){I(this,"name","eip155"),I(this,"client"),I(this,"chainId"),I(this,"namespace"),I(this,"httpProviders"),I(this,"events"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain());}async request(t){switch(t.request.method){case "eth_requestAccounts":return this.getAccounts();case "eth_accounts":return this.getAccounts();case "wallet_switchEthereumChain":return await this.handleSwitchChain(t);case "eth_chainId":return parseInt(this.getDefaultChain());case "wallet_getCapabilities":return await this.getCapabilities(t);case "wallet_getCallsStatus":return await this.getCallStatus(t)}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(parseInt(t),e),this.chainId=parseInt(t),this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,e){const i=e||p(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new o$3(new f(i,o$1("disableProviderPing")))}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const r=parseInt(P$1(e));t[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[e]);}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}async handleSwitchChain(t){var e,i;let r=t.request.params?(e=t.request.params[0])==null?void 0:e.chainId:"0x0";r=r.startsWith("0x")?r:`0x${r}`;const a=parseInt(r,16);if(this.isChainApproved(a))this.setDefaultChain(`${a}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:r}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${a}`);else throw new Error(`Failed to switch to chain 'eip155:${a}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}async getCapabilities(t){var e,i,r;const a=(i=(e=t.request)==null?void 0:e.params)==null?void 0:i[0];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(t.topic),c=((r=n?.sessionProperties)==null?void 0:r.capabilities)||{};if(c!=null&&c[a])return c?.[a];const h=await this.client.request(t);try{await this.client.session.update(t.topic,{sessionProperties:wt(Pt({},n.sessionProperties||{}),{capabilities:wt(Pt({},c||{}),{[a]:h})})});}catch(v){console.warn("Failed to update session with capabilities",v);}return h}async getCallStatus(t){var e,i;const r=this.client.session.get(t.topic),a=(e=r.sessionProperties)==null?void 0:e.bundler_name;if(a){const c=this.getBundlerUrl(t.chainId,a);try{return await this.getUserOperationReceipt(c,t)}catch(h){console.warn("Failed to fetch call status from bundler",h,c);}}const n=(i=r.sessionProperties)==null?void 0:i.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,t)}catch(c){console.warn("Failed to fetch call status from custom bundler",c,n);}if(this.namespace.methods.includes(t.request.method))return await this.client.request(t);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(t,e){var i;const r=new URL(t),a=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(formatJsonRpcRequest("eth_getUserOperationReceipt",[(i=e.request.params)==null?void 0:i[0]]))});if(!a.ok)throw new Error(`Failed to fetch user operation receipt - ${a.status}`);return await a.json()}getBundlerUrl(t,e){return `${qt}?projectId=${this.client.core.projectId}&chainId=${t}&bundler=${e}`}}var $e=Object.defineProperty,Oe=(s,t,e)=>t in s?$e(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,$$1=(s,t,e)=>Oe(s,typeof t!="symbol"?t+"":t,e);class Ae{constructor(t){$$1(this,"name","solana"),$$1(this,"client"),$$1(this,"httpProviders"),$$1(this,"events"),$$1(this,"namespace"),$$1(this,"chainId"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const r=P$1(e);t[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[e]);}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProvider(t,e){const i=e||p(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new o$3(new f(i,o$1("disableProviderPing")))}}var He=Object.defineProperty,Ee=(s,t,e)=>t in s?He(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,O$1=(s,t,e)=>Ee(s,typeof t!="symbol"?t+"":t,e);class Ce{constructor(t){O$1(this,"name","cosmos"),O$1(this,"client"),O$1(this,"httpProviders"),O$1(this,"events"),O$1(this,"namespace"),O$1(this,"chainId"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const r=P$1(e);t[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[e]);}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProvider(t,e){const i=e||p(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new o$3(new f(i,o$1("disableProviderPing")))}}var Ne=Object.defineProperty,Se=(s,t,e)=>t in s?Ne(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,A=(s,t,e)=>Se(s,typeof t!="symbol"?t+"":t,e);class De{constructor(t){A(this,"name","algorand"),A(this,"client"),A(this,"httpProviders"),A(this,"events"),A(this,"namespace"),A(this,"chainId"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){if(!this.httpProviders[t]){const i=e||p(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,i);}this.chainId=t,this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;t[e]=this.createHttpProvider(e,(i=this.namespace.rpcMap)==null?void 0:i[e]);}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProvider(t,e){const i=e||p(t,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new o$3(new f(i,o$1("disableProviderPing")))}}var qe=Object.defineProperty,je=(s,t,e)=>t in s?qe(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,H=(s,t,e)=>je(s,typeof t!="symbol"?t+"":t,e);class Re{constructor(t){H(this,"name","cip34"),H(this,"client"),H(this,"httpProviders"),H(this,"events"),H(this,"namespace"),H(this,"chainId"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`);}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{const i=this.getCardanoRPCUrl(e),r=P$1(e);t[r]=this.createHttpProvider(r,i);}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}getCardanoRPCUrl(t){const e=this.namespace.rpcMap;if(e)return e[t]}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProvider(t,e){const i=e||this.getCardanoRPCUrl(t);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new o$3(new f(i,o$1("disableProviderPing")))}}var _e=Object.defineProperty,Ue=(s,t,e)=>t in s?_e(s,t,{enumerable:true,configurable:true,writable:true,value:e}):s[t]=e,E=(s,t,e)=>Ue(s,typeof t!="symbol"?t+"":t,e);class Fe{constructor(t){E(this,"name","elrond"),E(this,"client"),E(this,"httpProviders"),E(this,"events"),E(this,"namespace"),E(this,"chainId"),this.namespace=t.namespace,this.events=o$1("events"),this.client=o$1("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders();}updateNamespace(t){this.namespace=Object.assign(this.namespace,t);}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,e){this.httpProviders[t]||this.setHttpProvider(t,e),this.chainId=t,this.events.emit(d.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`);}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(e=>{var i;const r=P$1(e);t[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[e]);}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,e=this.httpProviders[t];if(typeof e>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return e}setHttpProvider(t,e){const i=this.createHttpProvider(t,e);i&&(this.httpProviders[t]=i);}createHttpProvider(t,e){const i=e||p(t,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${t}`);return new o$3(new f(i,o$1("disableProviderPing")))}}var Le=Object.defineProperty,xe=(s,t,e)=>t in s?Le(s,t,{enumerable:true,configurable:true,writab